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.ByteBufAllocatorMetricProviderAn instance ofSafeAllocatormay 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 SafeAllocatorPOOLED_ALLOCATORstatic SafeAllocatorUNPOOLED_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 booleanisDirectBufferPooled()SafeAllocatorMetricmetric()protected io.netty.buffer.ByteBufnewDirectBuffer(int initialCapacity, int maxCapacity)protected io.netty.buffer.ByteBufnewHeapBuffer(int initialCapacity, int maxCapacity)protected voidreportLeak(java.lang.String message, int capacity, io.netty.buffer.ByteBuf buf, java.lang.Object hint)java.lang.StringtoString()-
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:
newHeapBufferin classio.netty.buffer.AbstractByteBufAllocator
-
newDirectBuffer
protected final io.netty.buffer.ByteBuf newDirectBuffer(int initialCapacity, int maxCapacity)- Specified by:
newDirectBufferin classio.netty.buffer.AbstractByteBufAllocator
-
isDirectBufferPooled
public final boolean isDirectBufferPooled()
- Specified by:
isDirectBufferPooledin interfaceio.netty.buffer.ByteBufAllocator
-
metric
public SafeAllocatorMetric metric()
- Specified by:
metricin 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:
toStringin classio.netty.buffer.AbstractByteBufAllocator
-
-