Package io.netty.util.internal
Interface Cleaner
-
- All Known Implementing Classes:
CleanerJava24Linker,CleanerJava25,CleanerJava6,CleanerJava9,DirectCleaner
interface CleanerAllows to free directByteBuffers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description CleanableDirectBufferallocate(int capacity)Create a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.voidfreeDirectBuffer(java.nio.ByteBuffer buffer)Deprecated.Instead allocate buffers fromallocate(int)and use the associatedCleanableDirectBuffer.clean()method.booleanhasExpensiveClean()Check if the clean operation is "relatively expensive".default CleanableDirectBufferreallocate(CleanableDirectBuffer old, int newCapacity)Reallocate a direct buffer with a new capacity.
-
-
-
Method Detail
-
allocate
CleanableDirectBuffer allocate(int capacity)
Create a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.- Parameters:
capacity- The desired capacity of the direct buffer.- Returns:
- The new
CleanableDirectBufferinstance.
-
reallocate
default CleanableDirectBuffer reallocate(CleanableDirectBuffer old, int newCapacity)
Reallocate a direct buffer with a new capacity. The old buffer is consumed and must not be used after this call.The default implementation allocates a new buffer, copies the data, and frees the old one. Implementations may override this to provide more efficient reallocation (e.g. via
Unsafe.reallocateMemory).
-
freeDirectBuffer
@Deprecated void freeDirectBuffer(java.nio.ByteBuffer buffer)
Deprecated.Instead allocate buffers fromallocate(int)and use the associatedCleanableDirectBuffer.clean()method.Free a directByteBufferif possible
-
hasExpensiveClean
boolean hasExpensiveClean()
Check if the clean operation is "relatively expensive". Expensive clean operations are fine for pooling allocators, but should be avoided for unpooled buffers.- Returns:
trueif this Cleaner has an expensive clean (i.e.CleanableDirectBuffer.clean()) operation.
-
-