Class PooledByteBufAllocator
java.lang.Object
io.netty.buffer.AbstractByteBufAllocator
io.netty.buffer.PooledByteBufAllocator
- All Implemented Interfaces:
ByteBufAllocator, ByteBufAllocatorMetricProvider
public class PooledByteBufAllocator
extends AbstractByteBufAllocator
implements ByteBufAllocatorMetricProvider
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPooledByteBufAllocator(boolean preferDirect) PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder) Deprecated.PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads) PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads, int directMemoryCacheAlignment) PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int tinyCacheSize, int smallCacheSize, int normalCacheSize) PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int tinyCacheSize, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads) PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int tinyCacheSize, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads, int directMemoryCacheAlignment) PooledByteBufAllocator(int nHeapArena, int nDirectArena, int pageSize, int maxOrder) -
Method Summary
Modifier and TypeMethodDescriptionfinal intDeprecated.static booleanDefault control creation of PoolThreadCache finalizers for FastThreadLocalThreads - System Property: io.netty.allocator.disableCacheFinalizersForFastThreadLocalThreads - default falsestatic intDefault maximum order - System Property: io.netty.allocator.maxOrder - default 9static intDefault normal cache size - System Property: io.netty.allocator.normalCacheSize - default 64static intDefault number of direct arenas - System Property: io.netty.allocator.numDirectArenas - default 2 * coresstatic intDefault number of heap arenas - System Property: io.netty.allocator.numHeapArenas - default 2 * coresstatic intDefault buffer page size - System Property: io.netty.allocator.pageSize - default 8192static booleanDefault prefer direct - System Property: io.netty.noPreferDirect - default falsestatic intDefault small cache size - System Property: io.netty.allocator.smallCacheSize - default 256static intDeprecated.Tiny caches have been merged into small caches.static booleanDefault thread caching behavior - System Property: io.netty.allocator.useCacheForAllThreads - default falseDeprecated.Returns the status of the allocator (which contains all metrics) as string.voidDeprecated.will be removed Free all cached buffers for the callingThread.booleanDeprecated.will be removed Returnstrueif the callingThreadhas aThreadLocalcache for the allocated buffers.Deprecated.booleanReturnstrueif directByteBuf's are pooledstatic booleanReturntrueif direct memory cache alignment is supported,falseotherwise.metric()Returns aByteBufAllocatorMetricfor aByteBufAllocator.protected ByteBufnewDirectBuffer(int initialCapacity, int maxCapacity) Create a directByteBufwith the given initialCapacity and maxCapacity.protected ByteBufnewHeapBuffer(int initialCapacity, int maxCapacity) Create a heapByteBufwith the given initialCapacity and maxCapacity.intDeprecated.intDeprecated.intDeprecated.intDeprecated.final longReturns the number of bytes of direct memory that is currently pinned to direct buffers allocated by aByteBufAllocator, or-1if unknown.final longReturns the number of bytes of heap memory that is currently pinned to heap buffers allocated by aByteBufAllocator, or-1if unknown.intDeprecated.intDeprecated.booleanTrim thread local cache for the currentThread, which will give back any cached memory that was not allocated frequently since the last trim operation.Methods inherited from class AbstractByteBufAllocator
buffer, buffer, buffer, calculateNewCapacity, compositeBuffer, compositeBuffer, compositeDirectBuffer, compositeDirectBuffer, compositeHeapBuffer, compositeHeapBuffer, directBuffer, directBuffer, directBuffer, heapBuffer, heapBuffer, heapBuffer, ioBuffer, ioBuffer, ioBuffer, toLeakAwareBuffer, toLeakAwareBuffer, toString
-
Field Details
-
DEFAULT
-
-
Constructor Details
-
PooledByteBufAllocator
public PooledByteBufAllocator() -
PooledByteBufAllocator
public PooledByteBufAllocator(boolean preferDirect) -
PooledByteBufAllocator
public PooledByteBufAllocator(int nHeapArena, int nDirectArena, int pageSize, int maxOrder) -
PooledByteBufAllocator
@Deprecated public PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder) -
PooledByteBufAllocator
@Deprecated public PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int tinyCacheSize, int smallCacheSize, int normalCacheSize) -
PooledByteBufAllocator
@Deprecated public PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int tinyCacheSize, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads) -
PooledByteBufAllocator
public PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads) -
PooledByteBufAllocator
@Deprecated public PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int tinyCacheSize, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads, int directMemoryCacheAlignment) -
PooledByteBufAllocator
public PooledByteBufAllocator(boolean preferDirect, int nHeapArena, int nDirectArena, int pageSize, int maxOrder, int smallCacheSize, int normalCacheSize, boolean useCacheForAllThreads, int directMemoryCacheAlignment)
-
-
Method Details
-
newHeapBuffer
Description copied from class:AbstractByteBufAllocatorCreate a heapByteBufwith the given initialCapacity and maxCapacity.- Specified by:
newHeapBufferin classAbstractByteBufAllocator
-
newDirectBuffer
Description copied from class:AbstractByteBufAllocatorCreate a directByteBufwith the given initialCapacity and maxCapacity.- Specified by:
newDirectBufferin classAbstractByteBufAllocator
-
defaultNumHeapArena
public static int defaultNumHeapArena()Default number of heap arenas - System Property: io.netty.allocator.numHeapArenas - default 2 * cores -
defaultNumDirectArena
public static int defaultNumDirectArena()Default number of direct arenas - System Property: io.netty.allocator.numDirectArenas - default 2 * cores -
defaultPageSize
public static int defaultPageSize()Default buffer page size - System Property: io.netty.allocator.pageSize - default 8192 -
defaultMaxOrder
public static int defaultMaxOrder()Default maximum order - System Property: io.netty.allocator.maxOrder - default 9 -
defaultDisableCacheFinalizersForFastThreadLocalThreads
public static boolean defaultDisableCacheFinalizersForFastThreadLocalThreads()Default control creation of PoolThreadCache finalizers for FastThreadLocalThreads - System Property: io.netty.allocator.disableCacheFinalizersForFastThreadLocalThreads - default false -
defaultUseCacheForAllThreads
public static boolean defaultUseCacheForAllThreads()Default thread caching behavior - System Property: io.netty.allocator.useCacheForAllThreads - default false -
defaultPreferDirect
public static boolean defaultPreferDirect()Default prefer direct - System Property: io.netty.noPreferDirect - default false -
defaultTinyCacheSize
Deprecated.Tiny caches have been merged into small caches.Default tiny cache size - default 0 -
defaultSmallCacheSize
public static int defaultSmallCacheSize()Default small cache size - System Property: io.netty.allocator.smallCacheSize - default 256 -
defaultNormalCacheSize
public static int defaultNormalCacheSize()Default normal cache size - System Property: io.netty.allocator.normalCacheSize - default 64 -
isDirectMemoryCacheAlignmentSupported
public static boolean isDirectMemoryCacheAlignmentSupported()Returntrueif direct memory cache alignment is supported,falseotherwise. -
isDirectBufferPooled
public boolean isDirectBufferPooled()Description copied from interface:ByteBufAllocatorReturnstrueif directByteBuf's are pooled- Specified by:
isDirectBufferPooledin interfaceByteBufAllocator
-
hasThreadLocalCache
Deprecated.will be removed Returnstrueif the callingThreadhas aThreadLocalcache for the allocated buffers. -
freeThreadLocalCache
Deprecated.will be removed Free all cached buffers for the callingThread. -
metric
Description copied from interface:ByteBufAllocatorMetricProviderReturns aByteBufAllocatorMetricfor aByteBufAllocator.- Specified by:
metricin interfaceByteBufAllocatorMetricProvider
-
numHeapArenas
Deprecated.Return the number of heap arenas. -
numDirectArenas
Deprecated.Return the number of direct arenas. -
heapArenas
Deprecated.Return aListof all heapPoolArenaMetrics that are provided by this pool. -
directArenas
Deprecated.Return aListof all directPoolArenaMetrics that are provided by this pool. -
numThreadLocalCaches
Deprecated.Return the number of thread local caches used by thisPooledByteBufAllocator. -
tinyCacheSize
Deprecated.Return the size of the tiny cache. -
smallCacheSize
Deprecated.Return the size of the small cache. -
normalCacheSize
Deprecated.Return the size of the normal cache. -
chunkSize
Deprecated.Return the chunk size for an arena. -
pinnedHeapMemory
public final long pinnedHeapMemory()Returns the number of bytes of heap memory that is currently pinned to heap buffers allocated by aByteBufAllocator, or-1if unknown. A buffer can pin more memory than its capacity might indicate, due to implementation details of the allocator. -
pinnedDirectMemory
public final long pinnedDirectMemory()Returns the number of bytes of direct memory that is currently pinned to direct buffers allocated by aByteBufAllocator, or-1if unknown. A buffer can pin more memory than its capacity might indicate, due to implementation details of the allocator. -
trimCurrentThreadCache
-
dumpStats
Returns the status of the allocator (which contains all metrics) as string. Be aware this may be expensive and so should not called too frequently.
-
PooledByteBufAllocator(boolean, int, int, int, int, int, int, boolean)