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
Simplistic
ByteBufAllocator implementation that does not pool anything.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UnpooledByteBufAllocatorDefault instance which uses leak-detection for direct buffers. -
Constructor Summary
ConstructorsConstructorDescriptionUnpooledByteBufAllocator(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
Modifier and TypeMethodDescriptioncompositeDirectBuffer(int maxNumComponents) Allocate a directCompositeByteBufwith the given maximum number of components that can be stored in it.compositeHeapBuffer(int maxNumComponents) Allocate a heapCompositeByteBufwith the given maximum number of components that can be stored in it.booleanReturnstrueif 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.Methods inherited from class AbstractByteBufAllocator
buffer, buffer, buffer, calculateNewCapacity, compositeBuffer, compositeBuffer, compositeDirectBuffer, 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.Allocate a heapCompositeByteBuf.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()
-
Field Details
-
DEFAULT
Default instance which uses leak-detection for direct buffers.
-
-
Constructor Details
-
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 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
-
compositeHeapBuffer
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
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
Description copied from interface:ByteBufAllocatorMetricProviderReturns aByteBufAllocatorMetricfor aByteBufAllocator.- Specified by:
metricin interfaceByteBufAllocatorMetricProvider
-