MemoryRegionCache$Entry objects are not recycled
Motivation: Even though MemoryRegionCache$Entry instances are allocated through a recycler they are not properly recycled, leaving a lot of instances to be GCed along with Recycler$DefaultHandle objects. Fixes #4071 Modification: Recycle Entry when done using it. Result: Less GCed objects.
This commit is contained in:
parent
cf171ff525
commit
0be53f296f
@ -386,7 +386,14 @@ final class PoolThreadCache {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public final boolean add(PoolChunk<T> chunk, long handle) {
|
||||
return queue.offer(newEntry(chunk, handle));
|
||||
Entry<T> entry = newEntry(chunk, handle);
|
||||
boolean queued = queue.offer(entry);
|
||||
if (!queued) {
|
||||
// If it was not possible to cache the chunk, immediately recycle the entry
|
||||
entry.recycle();
|
||||
}
|
||||
|
||||
return queued;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -398,6 +405,7 @@ final class PoolThreadCache {
|
||||
return false;
|
||||
}
|
||||
initBuf(entry.chunk, entry.handle, buf, reqCapacity);
|
||||
entry.recycle();
|
||||
|
||||
// allocations is not thread-safe which is fine as this is only called from the same thread all time.
|
||||
++ allocations;
|
||||
|
Loading…
Reference in New Issue
Block a user