Class SafeAllocator
- java.lang.Object
-
- io.netty.buffer.AbstractByteBufAllocator
-
- com.linkedin.alpini.base.safealloc.SafeAllocator
-
- All Implemented Interfaces:
io.netty.buffer.ByteBufAllocator
,io.netty.buffer.ByteBufAllocatorMetricProvider
public class SafeAllocator extends io.netty.buffer.AbstractByteBufAllocator implements io.netty.buffer.ByteBufAllocatorMetricProvider
An instance ofSafeAllocator
may be used to wrap an existing ByteBufAllocator to provide insurance against slow memory leaks from exceptional conditions by providing a means for the leaked ByteBuf objects to be reclaimed. Makes use of a reference queue per thread in order to avoid some of the synchronization costs.
-
-
Field Summary
Fields Modifier and Type Field Description static SafeAllocator
POOLED_ALLOCATOR
static SafeAllocator
UNPOOLED_ALLOCATOR
-
Constructor Summary
Constructors Constructor Description SafeAllocator(io.netty.buffer.ByteBufAllocator allocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isDirectBufferPooled()
SafeAllocatorMetric
metric()
protected io.netty.buffer.ByteBuf
newDirectBuffer(int initialCapacity, int maxCapacity)
protected io.netty.buffer.ByteBuf
newHeapBuffer(int initialCapacity, int maxCapacity)
protected void
reportLeak(java.lang.String message, int capacity, io.netty.buffer.ByteBuf buf, java.lang.Object hint)
java.lang.String
toString()
-
Methods inherited from class io.netty.buffer.AbstractByteBufAllocator
buffer, buffer, buffer, calculateNewCapacity, compositeBuffer, compositeBuffer, compositeDirectBuffer, compositeDirectBuffer, compositeHeapBuffer, compositeHeapBuffer, directBuffer, directBuffer, directBuffer, heapBuffer, heapBuffer, heapBuffer, ioBuffer, ioBuffer, ioBuffer, toLeakAwareBuffer, toLeakAwareBuffer
-
-
-
-
Field Detail
-
POOLED_ALLOCATOR
public static final SafeAllocator POOLED_ALLOCATOR
-
UNPOOLED_ALLOCATOR
public static final SafeAllocator UNPOOLED_ALLOCATOR
-
-
Method Detail
-
newHeapBuffer
protected final io.netty.buffer.ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity)
- Specified by:
newHeapBuffer
in classio.netty.buffer.AbstractByteBufAllocator
-
newDirectBuffer
protected final io.netty.buffer.ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity)
- Specified by:
newDirectBuffer
in classio.netty.buffer.AbstractByteBufAllocator
-
isDirectBufferPooled
public final boolean isDirectBufferPooled()
- Specified by:
isDirectBufferPooled
in interfaceio.netty.buffer.ByteBufAllocator
-
metric
public SafeAllocatorMetric metric()
- Specified by:
metric
in interfaceio.netty.buffer.ByteBufAllocatorMetricProvider
-
reportLeak
protected void reportLeak(java.lang.String message, int capacity, io.netty.buffer.ByteBuf buf, java.lang.Object hint)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classio.netty.buffer.AbstractByteBufAllocator
-
-