Interface ByteBufAllocatorBuilder
-
- All Known Implementing Classes:
ByteBufAllocatorBuilderImpl
public interface ByteBufAllocatorBuilder
Builder object to customize a ByteBuf allocator.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteBufAllocatorWithOomHandler
build()
Finalize the configuredByteBufAllocator
.static ByteBufAllocatorBuilder
create()
Creates a newByteBufAllocatorBuilder
.ByteBufAllocatorBuilder
exitOnOutOfMemory(boolean exitOnOutOfMemory)
ByteBufAllocatorBuilder
leakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)
Enable the leak detection for the allocator.ByteBufAllocatorBuilder
outOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)
Add a listener that is triggered whenever there is an allocation failure.ByteBufAllocatorBuilder
outOfMemoryPolicy(OutOfMemoryPolicy policy)
Define the OutOfMemory handling policy.ByteBufAllocatorBuilder
pooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)
Specify a custom allocator where the allocation requests should be forwarded to.ByteBufAllocatorBuilder
poolingConcurrency(int poolingConcurrency)
Controls the amount of concurrency for the memory pool.ByteBufAllocatorBuilder
poolingPolicy(PoolingPolicy policy)
Define the memory pooling policy.ByteBufAllocatorBuilder
unpooledAllocator(io.netty.buffer.ByteBufAllocator unpooledAllocator)
Specify a custom allocator where the allocation requests should be forwarded to.
-
-
-
Method Detail
-
create
static ByteBufAllocatorBuilder create()
Creates a newByteBufAllocatorBuilder
.
-
build
ByteBufAllocatorWithOomHandler build()
Finalize the configuredByteBufAllocator
.
-
pooledAllocator
ByteBufAllocatorBuilder pooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)
Specify a custom allocator where the allocation requests should be forwarded to.Default is to use a new instance of
PooledByteBufAllocator
.
-
unpooledAllocator
ByteBufAllocatorBuilder unpooledAllocator(io.netty.buffer.ByteBufAllocator unpooledAllocator)
Specify a custom allocator where the allocation requests should be forwarded to.Default is to use
UnpooledByteBufAllocator.DEFAULT
.
-
poolingPolicy
ByteBufAllocatorBuilder poolingPolicy(PoolingPolicy policy)
Define the memory pooling policy.Default is
PoolingPolicy.PooledDirect
-
poolingConcurrency
ByteBufAllocatorBuilder poolingConcurrency(int poolingConcurrency)
Controls the amount of concurrency for the memory pool.Default is to have a number of allocator arenas equals to 2 * CPUS.
Decreasing this number will reduce the amount of memory overhead, at the expense of increased allocation contention.
-
outOfMemoryPolicy
ByteBufAllocatorBuilder outOfMemoryPolicy(OutOfMemoryPolicy policy)
Define the OutOfMemory handling policy.Default is
OutOfMemoryPolicy.FallbackToHeap
-
outOfMemoryListener
ByteBufAllocatorBuilder outOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)
Add a listener that is triggered whenever there is an allocation failure.Application can use this to trigger alerting or process restarting.
-
leakDetectionPolicy
ByteBufAllocatorBuilder leakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)
Enable the leak detection for the allocator.Default is
LeakDetectionPolicy.Disabled
-
exitOnOutOfMemory
ByteBufAllocatorBuilder exitOnOutOfMemory(boolean exitOnOutOfMemory)
-
-