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
Simplistic
ByteBufAllocator
implementation that does not pool anything.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
private static final class
private static final class
private static final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UnpooledByteBufAllocator
Default instance which uses leak-detection for direct buffers.private final boolean
private final UnpooledByteBufAllocator.UnpooledByteBufAllocatorMetric
private final boolean
Fields inherited from class io.netty.buffer.AbstractByteBufAllocator
CALCULATE_THRESHOLD, DEFAULT_INITIAL_CAPACITY, DEFAULT_MAX_CAPACITY, DEFAULT_MAX_COMPONENTS
-
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 directCompositeByteBuf
with the given maximum number of components that can be stored in it.compositeHeapBuffer
(int maxNumComponents) Allocate a heapCompositeByteBuf
with the given maximum number of components that can be stored in it.(package private) void
decrementDirect
(int amount) (package private) void
decrementHeap
(int amount) (package private) void
incrementDirect
(int amount) (package private) void
incrementHeap
(int amount) boolean
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.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 Details
-
metric
-
disableLeakDetector
private final boolean disableLeakDetector -
noCleaner
private final boolean noCleaner -
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
-true
ifAbstractByteBufAllocator.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
-true
ifAbstractByteBufAllocator.buffer(int)
should try to allocate a direct buffer rather than a heap bufferdisableLeakDetector
-true
if 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
-true
ifAbstractByteBufAllocator.buffer(int)
should try to allocate a direct buffer rather than a heap bufferdisableLeakDetector
-true
if 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
-true
if we should try to usePlatformDependent.allocateDirectNoCleaner(int)
to allocate direct memory.
-
-
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
-
compositeHeapBuffer
Description copied from interface:ByteBufAllocator
Allocate a heapCompositeByteBuf
with the given maximum number of components that can be stored in it.- Specified by:
compositeHeapBuffer
in interfaceByteBufAllocator
- Overrides:
compositeHeapBuffer
in classAbstractByteBufAllocator
-
compositeDirectBuffer
Description copied from interface:ByteBufAllocator
Allocate a directCompositeByteBuf
with the given maximum number of components that can be stored in it.- Specified by:
compositeDirectBuffer
in interfaceByteBufAllocator
- Overrides:
compositeDirectBuffer
in classAbstractByteBufAllocator
-
isDirectBufferPooled
public boolean isDirectBufferPooled()Description copied from interface:ByteBufAllocator
Returnstrue
if directByteBuf
's are pooled- Specified by:
isDirectBufferPooled
in interfaceByteBufAllocator
-
metric
Description copied from interface:ByteBufAllocatorMetricProvider
Returns aByteBufAllocatorMetric
for aByteBufAllocator
.- Specified by:
metric
in interfaceByteBufAllocatorMetricProvider
-
incrementDirect
void incrementDirect(int amount) -
decrementDirect
void decrementDirect(int amount) -
incrementHeap
void incrementHeap(int amount) -
decrementHeap
void decrementHeap(int amount)
-