From 27945c8870c832970dfe15b9bf9f567c0ad96ea4 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 21 Feb 2025 22:50:19 +0000 Subject: despawn entities when switching worlds and some testbot fixes --- azalea-protocol/src/read.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'azalea-protocol/src') diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 01744169..84c307d7 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -117,6 +117,13 @@ fn parse_frame(buffer: &mut Cursor>) -> Result, FrameSplitterE // reset the inner vec once we've reached the end of the buffer so we don't keep // leaking memory buffer.get_mut().clear(); + + // we just cap the capacity to 64KB instead of resetting it to save some + // allocations. + // and the reason we bother capping it at all is to avoid wasting memory if we + // get a big packet once and then never again. + buffer.get_mut().shrink_to(1024 * 64); + buffer.set_position(0); } -- cgit v1.2.3