Package io.netty.buffer
Class UnpooledByteBufAllocator
- java.lang.Object
-
- io.netty.buffer.AbstractByteBufAllocator
-
- io.netty.buffer.UnpooledByteBufAllocator
-
- All Implemented Interfaces:
ByteBufAllocator,ByteBufAllocatorMetricProvider
public final class UnpooledByteBufAllocator extends AbstractByteBufAllocator implements ByteBufAllocatorMetricProvider
SimplisticByteBufAllocatorimplementation that does not pool anything.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classUnpooledByteBufAllocator.InstrumentedUnpooledDirectByteBufprivate static classUnpooledByteBufAllocator.InstrumentedUnpooledHeapByteBufprivate static classUnpooledByteBufAllocator.InstrumentedUnpooledUnsafeDirectByteBufprivate static classUnpooledByteBufAllocator.InstrumentedUnpooledUnsafeHeapByteBufprivate static classUnpooledByteBufAllocator.InstrumentedUnpooledUnsafeNoCleanerDirectByteBufprivate static classUnpooledByteBufAllocator.UnpooledByteBufAllocatorMetric
-
Field Summary
Fields Modifier and Type Field Description static UnpooledByteBufAllocatorDEFAULTDefault instance which uses leak-detection for direct buffers.private booleandisableLeakDetectorprivate UnpooledByteBufAllocator.UnpooledByteBufAllocatorMetricmetricprivate booleannoCleaner-
Fields inherited from class io.netty.buffer.AbstractByteBufAllocator
CALCULATE_THRESHOLD, DEFAULT_INITIAL_CAPACITY, DEFAULT_MAX_CAPACITY, DEFAULT_MAX_COMPONENTS
-
-
Constructor Summary
Constructors Constructor Description UnpooledByteBufAllocator(boolean preferDirect)Create a new instance which uses leak-detection for direct buffers.UnpooledByteBufAllocator(boolean preferDirect, boolean disableLeakDetector)Create a new instanceUnpooledByteBufAllocator(boolean preferDirect, boolean disableLeakDetector, boolean tryNoCleaner)Create a new instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompositeByteBufcompositeDirectBuffer(int maxNumComponents)Allocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.CompositeByteBufcompositeHeapBuffer(int maxNumComponents)Allocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.(package private) voiddecrementDirect(int amount)(package private) voiddecrementHeap(int amount)(package private) voidincrementDirect(int amount)(package private) voidincrementHeap(int amount)booleanisDirectBufferPooled()Returnstrueif directByteBuf's are pooledByteBufAllocatorMetricmetric()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.-
Methods inherited from class io.netty.buffer.AbstractByteBufAllocator
buffer, buffer, buffer, calculateNewCapacity, compositeBuffer, compositeBuffer, compositeDirectBuffer, compositeHeapBuffer, directBuffer, directBuffer, directBuffer, heapBuffer, heapBuffer, heapBuffer, ioBuffer, ioBuffer, ioBuffer, toLeakAwareBuffer, toLeakAwareBuffer, toString
-
-
-
-
Field Detail
-
metric
private final UnpooledByteBufAllocator.UnpooledByteBufAllocatorMetric metric
-
disableLeakDetector
private final boolean disableLeakDetector
-
noCleaner
private final boolean noCleaner
-
DEFAULT
public static final UnpooledByteBufAllocator DEFAULT
Default instance which uses leak-detection for direct buffers.
-
-
Constructor Detail
-
UnpooledByteBufAllocator
public UnpooledByteBufAllocator(boolean preferDirect)
Create a new instance which uses leak-detection for direct buffers.- Parameters:
preferDirect-trueifAbstractByteBufAllocator.buffer(int)should try to allocate a direct buffer rather than a heap buffer
-
UnpooledByteBufAllocator
public UnpooledByteBufAllocator(boolean preferDirect, boolean disableLeakDetector)Create a new instance- Parameters:
preferDirect-trueifAbstractByteBufAllocator.buffer(int)should try to allocate a direct buffer rather than a heap bufferdisableLeakDetector-trueif the leak-detection should be disabled completely for this allocator. This can be useful if the user just want to depend on the GC to handle direct buffers when not explicit released.
-
UnpooledByteBufAllocator
public UnpooledByteBufAllocator(boolean preferDirect, boolean disableLeakDetector, boolean tryNoCleaner)Create a new instance- Parameters:
preferDirect-trueifAbstractByteBufAllocator.buffer(int)should try to allocate a direct buffer rather than a heap bufferdisableLeakDetector-trueif the leak-detection should be disabled completely for this allocator. This can be useful if the user just want to depend on the GC to handle direct buffers when not explicit released.tryNoCleaner-trueif we should try to usePlatformDependent.allocateDirectNoCleaner(int)to allocate direct memory.
-
-
Method Detail
-
newHeapBuffer
protected ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity)
Description copied from class:AbstractByteBufAllocatorCreate a heapByteBufwith the given initialCapacity and maxCapacity.- Specified by:
newHeapBufferin classAbstractByteBufAllocator
-
newDirectBuffer
protected ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity)
Description copied from class:AbstractByteBufAllocatorCreate a directByteBufwith the given initialCapacity and maxCapacity.- Specified by:
newDirectBufferin classAbstractByteBufAllocator
-
compositeHeapBuffer
public CompositeByteBuf compositeHeapBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocatorAllocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.- Specified by:
compositeHeapBufferin interfaceByteBufAllocator- Overrides:
compositeHeapBufferin classAbstractByteBufAllocator
-
compositeDirectBuffer
public CompositeByteBuf compositeDirectBuffer(int maxNumComponents)
Description copied from interface:ByteBufAllocatorAllocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.- Specified by:
compositeDirectBufferin interfaceByteBufAllocator- Overrides:
compositeDirectBufferin classAbstractByteBufAllocator
-
isDirectBufferPooled
public boolean isDirectBufferPooled()
Description copied from interface:ByteBufAllocatorReturnstrueif directByteBuf's are pooled- Specified by:
isDirectBufferPooledin interfaceByteBufAllocator
-
metric
public ByteBufAllocatorMetric metric()
Description copied from interface:ByteBufAllocatorMetricProviderReturns aByteBufAllocatorMetricfor aByteBufAllocator.- Specified by:
metricin interfaceByteBufAllocatorMetricProvider
-
incrementDirect
void incrementDirect(int amount)
-
decrementDirect
void decrementDirect(int amount)
-
incrementHeap
void incrementHeap(int amount)
-
decrementHeap
void decrementHeap(int amount)
-
-