Class AdaptiveByteBufAllocator
java.lang.Object
io.netty.buffer.AbstractByteBufAllocator
io.netty.buffer.AdaptiveByteBufAllocator
- All Implemented Interfaces:
ByteBufAllocator, ByteBufAllocatorMetric, ByteBufAllocatorMetricProvider
@UnstableApi
public final class AdaptiveByteBufAllocator
extends AbstractByteBufAllocator
implements ByteBufAllocatorMetricProvider, ByteBufAllocatorMetric
An auto-tuning pooling
ByteBufAllocator, that follows an anti-generational hypothesis.
Note: this allocator is experimental. It is recommended to roll out usage slowly, and to carefully monitor application performance in the process.
See the AdaptivePoolingAllocator class documentation for implementation details.
-
Field Summary
Fields inherited from interface ByteBufAllocator
DEFAULT -
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveByteBufAllocator(boolean preferDirect) AdaptiveByteBufAllocator(boolean preferDirect, boolean useCacheForNonEventLoopThreads) -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif directByteBuf's are pooledmetric()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.longReturns the number of bytes of direct memory used by aByteBufAllocatoror-1if unknown.longReturns the number of bytes of heap memory used by aByteBufAllocatoror-1if unknown.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, toStringModifier and TypeMethodDescriptionbuffer()Allocate aByteBuf.buffer(int initialCapacity) Allocate aByteBufwith the given initial capacity.buffer(int initialCapacity, int maxCapacity) Allocate aByteBufwith the given initial capacity and the given maximal capacity.intcalculateNewCapacity(int minNewCapacity, int maxCapacity) Allocate aCompositeByteBuf.compositeBuffer(int maxNumComponents) Allocate aCompositeByteBufwith the given maximum number of components that can be stored in it.Allocate a directCompositeByteBuf.compositeDirectBuffer(int maxNumComponents) Allocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.Allocate a heapCompositeByteBuf.compositeHeapBuffer(int maxNumComponents) Allocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.Allocate a directByteBuf.directBuffer(int initialCapacity) Allocate a directByteBufwith the given initial capacity.directBuffer(int initialCapacity, int maxCapacity) Allocate a directByteBufwith the given initial capacity and the given maximal capacity.Allocate a heapByteBuf.heapBuffer(int initialCapacity) Allocate a heapByteBufwith the given initial capacity.heapBuffer(int initialCapacity, int maxCapacity) Allocate a heapByteBufwith the given initial capacity and the given maximal capacity.ioBuffer()Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.ioBuffer(int initialCapacity) Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.ioBuffer(int initialCapacity, int maxCapacity) Allocate aByteBuf, preferably a direct buffer which is suitable for I/O.protected static ByteBuftoLeakAwareBuffer(ByteBuf buf) protected static CompositeByteBuftoString()
-
Constructor Details
-
AdaptiveByteBufAllocator
public AdaptiveByteBufAllocator() -
AdaptiveByteBufAllocator
public AdaptiveByteBufAllocator(boolean preferDirect) -
AdaptiveByteBufAllocator
public AdaptiveByteBufAllocator(boolean preferDirect, boolean useCacheForNonEventLoopThreads)
-
-
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
-
isDirectBufferPooled
public boolean isDirectBufferPooled()Description copied from interface:ByteBufAllocatorReturnstrueif directByteBuf's are pooled- Specified by:
isDirectBufferPooledin interfaceByteBufAllocator
-
usedHeapMemory
public long usedHeapMemory()Description copied from interface:ByteBufAllocatorMetricReturns the number of bytes of heap memory used by aByteBufAllocatoror-1if unknown.- Specified by:
usedHeapMemoryin interfaceByteBufAllocatorMetric
-
usedDirectMemory
public long usedDirectMemory()Description copied from interface:ByteBufAllocatorMetricReturns the number of bytes of direct memory used by aByteBufAllocatoror-1if unknown.- Specified by:
usedDirectMemoryin interfaceByteBufAllocatorMetric
-
metric
Description copied from interface:ByteBufAllocatorMetricProviderReturns aByteBufAllocatorMetricfor aByteBufAllocator.- Specified by:
metricin interfaceByteBufAllocatorMetricProvider
-