Dereference when calling PooledByteBuf.deallocate()

Motivation:

We missed to dereference the chunk and tmpNioBuf when calling deallocate(). This means the GC can not collect these as we still hold a reference while have the PooledByteBuf in the recycler stack.

Modifications:

Dereference chunk and tmpNioBuf.

Result:

GC can collect things.
This commit is contained in:
Norman Maurer 2015-04-10 15:46:53 +02:00
parent 1e8a2e69db
commit 7094c7b797

View File

@ -143,10 +143,14 @@ abstract class PooledByteBuf<T> extends AbstractReferenceCountedByteBuf {
if (handle >= 0) {
final long handle = this.handle;
this.handle = -1;
memory = null;
boolean sameThread = initThread == Thread.currentThread();
initThread = null;
chunk.arena.free(chunk, handle, maxLength, sameThread);
// Dereference everything so GC can do it's work.
chunk = null;
tmpNioBuf = null;
initThread = null;
memory = null;
recycle();
}
}