Skip to content

Commit 1751440

Browse files
authored
make 'cache = null' to help PoolThreadCache finalizer. (#12881)
Motivation: PoolByteBuf deallocate doesn't set `cache = null` when deallocate PoolByteBuf, so the PollThreadCache is always reachable by GC root. It is reachable until the cache is overridden at the next init. Modifications: Set cache to null when `deallocate()` method is called. Result: More timely deallocation of `PoolThreadCache` possible.
1 parent 937bb67 commit 1751440

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

buffer/src/main/java/io/netty/buffer/PooledByteBuf.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ protected final void deallocate() {
176176
chunk.arena.free(chunk, tmpNioBuf, handle, maxLength, cache);
177177
tmpNioBuf = null;
178178
chunk = null;
179+
cache = null;
179180
recycle();
180181
}
181182
}

0 commit comments

Comments
 (0)