From 9bd0e4829bd08a5ed0860aafc6288290ceac5eae Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Sat, 27 Feb 2021 18:02:59 +0200 Subject: Fix memory leak in ScreenNetworking --- .../io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java index 0d9a74e..cd2651a 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/ScreenNetworkingImpl.java @@ -92,7 +92,13 @@ public class ScreenNetworkingImpl implements ScreenNetworking { if (receiver != null) { buf.retain(); - executor.execute(() -> receiver.onMessage(buf)); + executor.execute(() -> { + try { + receiver.onMessage(buf); + } finally { + buf.release(); + } + }); } else { LOGGER.warn("Message {} not registered for {} on side {}", messageId, screenHandler, networking.side); } -- cgit