Package io.netty.buffer
Class PoolArena<T>
- java.lang.Object
-
- io.netty.buffer.PoolArena<T>
-
- All Implemented Interfaces:
PoolArenaMetric
- Direct Known Subclasses:
PoolArena.DirectArena,PoolArena.HeapArena
abstract class PoolArena<T> extends java.lang.Object implements PoolArenaMetric
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classPoolArena.DirectArena(package private) static classPoolArena.HeapArena(package private) static classPoolArena.SizeClass
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedPoolArena(PooledByteBufAllocator parent, int pageSize, int maxOrder, int pageShifts, int chunkSize, int cacheAlignment)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) intalignCapacity(int reqCapacity)(package private) PooledByteBuf<T>allocate(PoolThreadCache cache, int reqCapacity, int maxCapacity)private voidallocate(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity)private voidallocateHuge(PooledByteBuf<T> buf, int reqCapacity)private voidallocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity, PoolThreadCache threadCache)private static voidappendPoolSubPages(java.lang.StringBuilder buf, PoolSubpage<?>[] subpages)java.util.List<PoolChunkListMetric>chunkLists()Returns an unmodifiableListwhich holdsPoolChunkListMetrics.protected abstract voiddestroyChunk(PoolChunk<T> chunk)private voiddestroyPoolChunkLists(PoolChunkList<T>... chunkLists)private static voiddestroyPoolSubPages(PoolSubpage<?>[] pages)protected voidfinalize()(package private) PoolSubpage<T>findSubpagePoolHead(int elemSize)(package private) voidfree(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity, PoolThreadCache cache)(package private) voidfreeChunk(PoolChunk<T> chunk, long handle, PoolArena.SizeClass sizeClass, java.nio.ByteBuffer nioBuffer, boolean finalizer)private voidincTinySmallAllocation(boolean tiny)(package private) abstract booleanisDirect()(package private) static booleanisTiny(int normCapacity)(package private) booleanisTinyOrSmall(int normCapacity)protected abstract voidmemoryCopy(T src, int srcOffset, PooledByteBuf<T> dst, int length)protected abstract PooledByteBuf<T>newByteBuf(int maxCapacity)protected abstract PoolChunk<T>newChunk(int pageSize, int maxOrder, int pageShifts, int chunkSize)private PoolSubpage<T>[]newSubpagePoolArray(int size)private PoolSubpage<T>newSubpagePoolHead(int pageSize)protected abstract PoolChunk<T>newUnpooledChunk(int capacity)(package private) intnormalizeCapacity(int reqCapacity)longnumActiveAllocations()Return the number of currently active allocations.longnumActiveBytes()Return the number of active bytes that are currently allocated by the arena.longnumActiveHugeAllocations()Return the number of currently active huge allocations.longnumActiveNormalAllocations()Return the number of currently active normal allocations.longnumActiveSmallAllocations()Return the number of currently active small allocations.longnumActiveTinyAllocations()Return the number of currently active tiny allocations.longnumAllocations()Return the number of allocations done via the arena.intnumChunkLists()Returns the number of chunk lists for the arena.longnumDeallocations()Return the number of deallocations done via the arena.longnumHugeAllocations()Return the number of huge allocations done via the arena.longnumHugeDeallocations()Return the number of huge deallocations done via the arena.longnumNormalAllocations()Return the number of normal allocations done via the arena.longnumNormalDeallocations()Return the number of normal deallocations done via the arena.longnumSmallAllocations()Return the number of small allocations done via the arena.longnumSmallDeallocations()Return the number of small deallocations done via the arena.intnumSmallSubpages()Returns the number of small sub-pages for the arena.intnumThreadCaches()Returns the number of thread caches backed by this arena.longnumTinyAllocations()Return the number of tiny allocations done via the arena.longnumTinyDeallocations()Return the number of tiny deallocations done via the arena.intnumTinySubpages()Returns the number of tiny sub-pages for the arena.(package private) voidreallocate(PooledByteBuf<T> buf, int newCapacity, boolean freeOldMemory)private PoolArena.SizeClasssizeClass(int normCapacity)(package private) static intsmallIdx(int normCapacity)java.util.List<PoolSubpageMetric>smallSubpages()Returns an unmodifiableListwhich holdsPoolSubpageMetrics for small sub-pages.private static java.util.List<PoolSubpageMetric>subPageMetricList(PoolSubpage<?>[] pages)(package private) static inttinyIdx(int normCapacity)java.util.List<PoolSubpageMetric>tinySubpages()Returns an unmodifiableListwhich holdsPoolSubpageMetrics for tiny sub-pages.java.lang.StringtoString()
-
-
-
Field Detail
-
HAS_UNSAFE
static final boolean HAS_UNSAFE
-
numTinySubpagePools
static final int numTinySubpagePools
- See Also:
- Constant Field Values
-
parent
final PooledByteBufAllocator parent
-
maxOrder
private final int maxOrder
-
pageSize
final int pageSize
-
pageShifts
final int pageShifts
-
chunkSize
final int chunkSize
-
subpageOverflowMask
final int subpageOverflowMask
-
numSmallSubpagePools
final int numSmallSubpagePools
-
directMemoryCacheAlignment
final int directMemoryCacheAlignment
-
directMemoryCacheAlignmentMask
final int directMemoryCacheAlignmentMask
-
tinySubpagePools
private final PoolSubpage<T>[] tinySubpagePools
-
smallSubpagePools
private final PoolSubpage<T>[] smallSubpagePools
-
q050
private final PoolChunkList<T> q050
-
q025
private final PoolChunkList<T> q025
-
q000
private final PoolChunkList<T> q000
-
qInit
private final PoolChunkList<T> qInit
-
q075
private final PoolChunkList<T> q075
-
q100
private final PoolChunkList<T> q100
-
chunkListMetrics
private final java.util.List<PoolChunkListMetric> chunkListMetrics
-
allocationsNormal
private long allocationsNormal
-
allocationsTiny
private final LongCounter allocationsTiny
-
allocationsSmall
private final LongCounter allocationsSmall
-
allocationsHuge
private final LongCounter allocationsHuge
-
activeBytesHuge
private final LongCounter activeBytesHuge
-
deallocationsTiny
private long deallocationsTiny
-
deallocationsSmall
private long deallocationsSmall
-
deallocationsNormal
private long deallocationsNormal
-
deallocationsHuge
private final LongCounter deallocationsHuge
-
numThreadCaches
final java.util.concurrent.atomic.AtomicInteger numThreadCaches
-
-
Constructor Detail
-
PoolArena
protected PoolArena(PooledByteBufAllocator parent, int pageSize, int maxOrder, int pageShifts, int chunkSize, int cacheAlignment)
-
-
Method Detail
-
newSubpagePoolHead
private PoolSubpage<T> newSubpagePoolHead(int pageSize)
-
newSubpagePoolArray
private PoolSubpage<T>[] newSubpagePoolArray(int size)
-
isDirect
abstract boolean isDirect()
-
allocate
PooledByteBuf<T> allocate(PoolThreadCache cache, int reqCapacity, int maxCapacity)
-
tinyIdx
static int tinyIdx(int normCapacity)
-
smallIdx
static int smallIdx(int normCapacity)
-
isTinyOrSmall
boolean isTinyOrSmall(int normCapacity)
-
isTiny
static boolean isTiny(int normCapacity)
-
allocate
private void allocate(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity)
-
allocateNormal
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int normCapacity, PoolThreadCache threadCache)
-
incTinySmallAllocation
private void incTinySmallAllocation(boolean tiny)
-
allocateHuge
private void allocateHuge(PooledByteBuf<T> buf, int reqCapacity)
-
free
void free(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity, PoolThreadCache cache)
-
sizeClass
private PoolArena.SizeClass sizeClass(int normCapacity)
-
freeChunk
void freeChunk(PoolChunk<T> chunk, long handle, PoolArena.SizeClass sizeClass, java.nio.ByteBuffer nioBuffer, boolean finalizer)
-
findSubpagePoolHead
PoolSubpage<T> findSubpagePoolHead(int elemSize)
-
normalizeCapacity
int normalizeCapacity(int reqCapacity)
-
alignCapacity
int alignCapacity(int reqCapacity)
-
reallocate
void reallocate(PooledByteBuf<T> buf, int newCapacity, boolean freeOldMemory)
-
numThreadCaches
public int numThreadCaches()
Description copied from interface:PoolArenaMetricReturns the number of thread caches backed by this arena.- Specified by:
numThreadCachesin interfacePoolArenaMetric
-
numTinySubpages
public int numTinySubpages()
Description copied from interface:PoolArenaMetricReturns the number of tiny sub-pages for the arena.- Specified by:
numTinySubpagesin interfacePoolArenaMetric
-
numSmallSubpages
public int numSmallSubpages()
Description copied from interface:PoolArenaMetricReturns the number of small sub-pages for the arena.- Specified by:
numSmallSubpagesin interfacePoolArenaMetric
-
numChunkLists
public int numChunkLists()
Description copied from interface:PoolArenaMetricReturns the number of chunk lists for the arena.- Specified by:
numChunkListsin interfacePoolArenaMetric
-
tinySubpages
public java.util.List<PoolSubpageMetric> tinySubpages()
Description copied from interface:PoolArenaMetricReturns an unmodifiableListwhich holdsPoolSubpageMetrics for tiny sub-pages.- Specified by:
tinySubpagesin interfacePoolArenaMetric
-
smallSubpages
public java.util.List<PoolSubpageMetric> smallSubpages()
Description copied from interface:PoolArenaMetricReturns an unmodifiableListwhich holdsPoolSubpageMetrics for small sub-pages.- Specified by:
smallSubpagesin interfacePoolArenaMetric
-
chunkLists
public java.util.List<PoolChunkListMetric> chunkLists()
Description copied from interface:PoolArenaMetricReturns an unmodifiableListwhich holdsPoolChunkListMetrics.- Specified by:
chunkListsin interfacePoolArenaMetric
-
subPageMetricList
private static java.util.List<PoolSubpageMetric> subPageMetricList(PoolSubpage<?>[] pages)
-
numAllocations
public long numAllocations()
Description copied from interface:PoolArenaMetricReturn the number of allocations done via the arena. This includes all sizes.- Specified by:
numAllocationsin interfacePoolArenaMetric
-
numTinyAllocations
public long numTinyAllocations()
Description copied from interface:PoolArenaMetricReturn the number of tiny allocations done via the arena.- Specified by:
numTinyAllocationsin interfacePoolArenaMetric
-
numSmallAllocations
public long numSmallAllocations()
Description copied from interface:PoolArenaMetricReturn the number of small allocations done via the arena.- Specified by:
numSmallAllocationsin interfacePoolArenaMetric
-
numNormalAllocations
public long numNormalAllocations()
Description copied from interface:PoolArenaMetricReturn the number of normal allocations done via the arena.- Specified by:
numNormalAllocationsin interfacePoolArenaMetric
-
numDeallocations
public long numDeallocations()
Description copied from interface:PoolArenaMetricReturn the number of deallocations done via the arena. This includes all sizes.- Specified by:
numDeallocationsin interfacePoolArenaMetric
-
numTinyDeallocations
public long numTinyDeallocations()
Description copied from interface:PoolArenaMetricReturn the number of tiny deallocations done via the arena.- Specified by:
numTinyDeallocationsin interfacePoolArenaMetric
-
numSmallDeallocations
public long numSmallDeallocations()
Description copied from interface:PoolArenaMetricReturn the number of small deallocations done via the arena.- Specified by:
numSmallDeallocationsin interfacePoolArenaMetric
-
numNormalDeallocations
public long numNormalDeallocations()
Description copied from interface:PoolArenaMetricReturn the number of normal deallocations done via the arena.- Specified by:
numNormalDeallocationsin interfacePoolArenaMetric
-
numHugeAllocations
public long numHugeAllocations()
Description copied from interface:PoolArenaMetricReturn the number of huge allocations done via the arena.- Specified by:
numHugeAllocationsin interfacePoolArenaMetric
-
numHugeDeallocations
public long numHugeDeallocations()
Description copied from interface:PoolArenaMetricReturn the number of huge deallocations done via the arena.- Specified by:
numHugeDeallocationsin interfacePoolArenaMetric
-
numActiveAllocations
public long numActiveAllocations()
Description copied from interface:PoolArenaMetricReturn the number of currently active allocations.- Specified by:
numActiveAllocationsin interfacePoolArenaMetric
-
numActiveTinyAllocations
public long numActiveTinyAllocations()
Description copied from interface:PoolArenaMetricReturn the number of currently active tiny allocations.- Specified by:
numActiveTinyAllocationsin interfacePoolArenaMetric
-
numActiveSmallAllocations
public long numActiveSmallAllocations()
Description copied from interface:PoolArenaMetricReturn the number of currently active small allocations.- Specified by:
numActiveSmallAllocationsin interfacePoolArenaMetric
-
numActiveNormalAllocations
public long numActiveNormalAllocations()
Description copied from interface:PoolArenaMetricReturn the number of currently active normal allocations.- Specified by:
numActiveNormalAllocationsin interfacePoolArenaMetric
-
numActiveHugeAllocations
public long numActiveHugeAllocations()
Description copied from interface:PoolArenaMetricReturn the number of currently active huge allocations.- Specified by:
numActiveHugeAllocationsin interfacePoolArenaMetric
-
numActiveBytes
public long numActiveBytes()
Description copied from interface:PoolArenaMetricReturn the number of active bytes that are currently allocated by the arena.- Specified by:
numActiveBytesin interfacePoolArenaMetric
-
newChunk
protected abstract PoolChunk<T> newChunk(int pageSize, int maxOrder, int pageShifts, int chunkSize)
-
newByteBuf
protected abstract PooledByteBuf<T> newByteBuf(int maxCapacity)
-
memoryCopy
protected abstract void memoryCopy(T src, int srcOffset, PooledByteBuf<T> dst, int length)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
appendPoolSubPages
private static void appendPoolSubPages(java.lang.StringBuilder buf, PoolSubpage<?>[] subpages)
-
finalize
protected final void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
destroyPoolSubPages
private static void destroyPoolSubPages(PoolSubpage<?>[] pages)
-
destroyPoolChunkLists
private void destroyPoolChunkLists(PoolChunkList<T>... chunkLists)
-
-