Class CleanerJava24Linker
java.lang.Object
io.netty.util.internal.CleanerJava24Linker
- All Implemented Interfaces:
Cleaner
Allocates direct buffers with malloc and free from libc, linked through the Foreign Function & Memory API.
The FFM API is compiled against the netty-ffm-stub module. It and the signature-polymorphic
MethodHandle calls are only used from the nested classes, which are only loaded on Java versions that
have the FFM API, so this class still loads and verifies where it is missing (e.g. Android).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classprivate static final classLinks malloc and free on first use rather than whenPlatformDependentis initialized, because creating the downcall handles is a startup cost for applications that may never allocate a direct buffer.private static final classChecks that native access is enabled for this module, and that this platform has a 64-bit native linker that finds malloc and free. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final InternalLoggerprivate static final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate(int capacity) Create a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.(package private) static voidfree(long memoryAddress) voidfreeDirectBuffer(java.nio.ByteBuffer buffer) Free a directByteBufferif possiblebooleanCheck if the clean operation is "relatively expensive".(package private) static boolean(package private) static longmalloc(int capacity) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Cleaner
reallocate
-
Field Details
-
logger
-
SUPPORTED
private static final boolean SUPPORTED
-
-
Constructor Details
-
CleanerJava24Linker
public CleanerJava24Linker()
-
-
Method Details
-
isSupported
static boolean isSupported() -
allocate
Description copied from interface:CleanerCreate a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.- Specified by:
allocatein interfaceCleaner- Parameters:
capacity- The desired capacity of the direct buffer.- Returns:
- The new
CleanableDirectBufferinstance.
-
freeDirectBuffer
public void freeDirectBuffer(java.nio.ByteBuffer buffer) Description copied from interface:CleanerFree a directByteBufferif possible- Specified by:
freeDirectBufferin interfaceCleaner
-
hasExpensiveClean
public boolean hasExpensiveClean()Description copied from interface:CleanerCheck if the clean operation is "relatively expensive". Expensive clean operations are fine for pooling allocators, but should be avoided for unpooled buffers.- Specified by:
hasExpensiveCleanin interfaceCleaner- Returns:
trueif this Cleaner has an expensive clean (i.e.CleanableDirectBuffer.clean()) operation.
-
malloc
static long malloc(int capacity) -
free
static void free(long memoryAddress)
-