Package io.netty.buffer
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
private static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final boolean
private final AdaptiveByteBufAllocator.AdaptiveAllocatorApi
private final AdaptiveByteBufAllocator.AdaptiveAllocatorApi
private static final InternalLogger
Fields inherited from class io.netty.buffer.AbstractByteBufAllocator
CALCULATE_THRESHOLD, DEFAULT_INITIAL_CAPACITY, DEFAULT_MAX_CAPACITY, DEFAULT_MAX_COMPONENTS
Fields inherited from interface io.netty.buffer.ByteBufAllocator
DEFAULT
-
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveByteBufAllocator
(boolean preferDirect) AdaptiveByteBufAllocator
(boolean preferDirect, boolean useCacheForNonEventLoopThreads) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if directByteBuf
's are pooledmetric()
Returns aByteBufAllocatorMetric
for aByteBufAllocator
.protected ByteBuf
newDirectBuffer
(int initialCapacity, int maxCapacity) Create a directByteBuf
with the given initialCapacity and maxCapacity.protected ByteBuf
newHeapBuffer
(int initialCapacity, int maxCapacity) Create a heapByteBuf
with the given initialCapacity and maxCapacity.long
Returns the number of bytes of direct memory used by aByteBufAllocator
or-1
if unknown.long
Returns the number of bytes of heap memory used by aByteBufAllocator
or-1
if unknown.Methods inherited from class io.netty.buffer.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
-
logger
-
DEFAULT_USE_CACHED_MAGAZINES_FOR_NON_EVENT_LOOP_THREADS
private static final boolean DEFAULT_USE_CACHED_MAGAZINES_FOR_NON_EVENT_LOOP_THREADS -
direct
-
heap
-
-
Constructor Details
-
AdaptiveByteBufAllocator
public AdaptiveByteBufAllocator() -
AdaptiveByteBufAllocator
public AdaptiveByteBufAllocator(boolean preferDirect) -
AdaptiveByteBufAllocator
public AdaptiveByteBufAllocator(boolean preferDirect, boolean useCacheForNonEventLoopThreads)
-
-
Method Details
-
newHeapBuffer
Description copied from class:AbstractByteBufAllocator
Create a heapByteBuf
with the given initialCapacity and maxCapacity.- Specified by:
newHeapBuffer
in classAbstractByteBufAllocator
-
newDirectBuffer
Description copied from class:AbstractByteBufAllocator
Create a directByteBuf
with the given initialCapacity and maxCapacity.- Specified by:
newDirectBuffer
in classAbstractByteBufAllocator
-
isDirectBufferPooled
public boolean isDirectBufferPooled()Description copied from interface:ByteBufAllocator
Returnstrue
if directByteBuf
's are pooled- Specified by:
isDirectBufferPooled
in interfaceByteBufAllocator
-
usedHeapMemory
public long usedHeapMemory()Description copied from interface:ByteBufAllocatorMetric
Returns the number of bytes of heap memory used by aByteBufAllocator
or-1
if unknown.- Specified by:
usedHeapMemory
in interfaceByteBufAllocatorMetric
-
usedDirectMemory
public long usedDirectMemory()Description copied from interface:ByteBufAllocatorMetric
Returns the number of bytes of direct memory used by aByteBufAllocator
or-1
if unknown.- Specified by:
usedDirectMemory
in interfaceByteBufAllocatorMetric
-
metric
Description copied from interface:ByteBufAllocatorMetricProvider
Returns aByteBufAllocatorMetric
for aByteBufAllocator
.- Specified by:
metric
in interfaceByteBufAllocatorMetricProvider
-