Interface ByteBufAllocatorBuilder
- All Known Implementing Classes:
ByteBufAllocatorBuilderImpl
public interface ByteBufAllocatorBuilder
Builder object to customize a ByteBuf allocator.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Finalize the configuredByteBufAllocator.static ByteBufAllocatorBuildercreate()Creates a newByteBufAllocatorBuilder.exitOnOutOfMemory(boolean exitOnOutOfMemory) leakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy) Enable the leak detection for the allocator.outOfMemoryListener(Consumer<OutOfMemoryError> listener) Add a listener that is triggered whenever there is an allocation failure.outOfMemoryPolicy(OutOfMemoryPolicy policy) Define the OutOfMemory handling policy.pooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator) Specify a custom allocator where the allocation requests should be forwarded to.poolingConcurrency(int poolingConcurrency) Controls the amount of concurrency for the memory pool.poolingPolicy(PoolingPolicy policy) Define the memory pooling policy.unpooledAllocator(io.netty.buffer.ByteBufAllocator unpooledAllocator) Specify a custom allocator where the allocation requests should be forwarded to.
-
Method Details
-
create
Creates a newByteBufAllocatorBuilder. -
build
ByteBufAllocatorWithOomHandler build()Finalize the configuredByteBufAllocator. -
pooledAllocator
Specify a custom allocator where the allocation requests should be forwarded to.Default is to use a new instance of
PooledByteBufAllocator. -
unpooledAllocator
Specify a custom allocator where the allocation requests should be forwarded to.Default is to use
UnpooledByteBufAllocator.DEFAULT. -
poolingPolicy
Define the memory pooling policy.Default is
PoolingPolicy.PooledDirect -
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
Define the OutOfMemory handling policy.Default is
OutOfMemoryPolicy.FallbackToHeap -
outOfMemoryListener
Add a listener that is triggered whenever there is an allocation failure.Application can use this to trigger alerting or process restarting.
-
leakDetectionPolicy
Enable the leak detection for the allocator.Default is
LeakDetectionPolicy.Disabled -
exitOnOutOfMemory
-