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
1e8a2e69db
commit
7094c7b797
@ -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