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:
parent
675b5641f4
commit
326d57f0c3
@ -143,10 +143,14 @@ abstract class PooledByteBuf<T> extends AbstractReferenceCountedByteBuf {
|
|||||||
if (handle >= 0) {
|
if (handle >= 0) {
|
||||||
final long handle = this.handle;
|
final long handle = this.handle;
|
||||||
this.handle = -1;
|
this.handle = -1;
|
||||||
memory = null;
|
|
||||||
boolean sameThread = initThread == Thread.currentThread();
|
boolean sameThread = initThread == Thread.currentThread();
|
||||||
initThread = null;
|
|
||||||
chunk.arena.free(chunk, handle, maxLength, sameThread);
|
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();
|
recycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user