From 217b8e255c05887a30803a6c96abac1d320c3d8b Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 20 Aug 2013 21:15:05 +0200 Subject: [PATCH] [#1763] Fill ChannelOutboundBuffer.nioBuffers with null on close to allow the content to be GC'ed --- .../main/java/io/netty/channel/ChannelOutboundBuffer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java index 9daedad818..45be347994 100644 --- a/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java +++ b/transport/src/main/java/io/netty/channel/ChannelOutboundBuffer.java @@ -30,6 +30,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; +import java.util.Arrays; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLongFieldUpdater; @@ -463,6 +464,10 @@ public final class ChannelOutboundBuffer { } finally { tail = unflushed; inFail = false; + + // null out the nio buffers array so the can be GC'ed + // https://github.com/netty/netty/issues/1763 + Arrays.fill(nioBuffers, null); } RECYCLER.recycle(this, handle);