Interface ByteBufAllocatorBuilder
-
- All Known Implementing Classes:
ByteBufAllocatorBuilderImpl
public interface ByteBufAllocatorBuilderBuilder object to customize a ByteBuf allocator.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteBufAllocatorWithOomHandlerbuild()Finalize the configuredByteBufAllocator.static ByteBufAllocatorBuildercreate()Creates a newByteBufAllocatorBuilder.ByteBufAllocatorBuilderexitOnOutOfMemory(boolean exitOnOutOfMemory)ByteBufAllocatorBuilderleakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)Enable the leak detection for the allocator.ByteBufAllocatorBuilderoutOfMemoryListener(java.util.function.Consumer<java.lang.OutOfMemoryError> listener)Add a listener that is triggered whenever there is an allocation failure.ByteBufAllocatorBuilderoutOfMemoryPolicy(OutOfMemoryPolicy policy)Define the OutOfMemory handling policy.ByteBufAllocatorBuilderpooledAllocator(io.netty.buffer.ByteBufAllocator pooledAllocator)Specify a custom allocator where the allocation requests should be forwarded to.ByteBufAllocatorBuilderpoolingConcurrency(int poolingConcurrency)Controls the amount of concurrency for the memory pool.ByteBufAllocatorBuilderpoolingPolicy(PoolingPolicy policy)Define the memory pooling policy.ByteBufAllocatorBuilderunpooledAllocator(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)
-
-