Class CleanerJava24Linker

  • All Implemented Interfaces:
    Cleaner

    public class CleanerJava24Linker
    extends java.lang.Object
    implements 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).

    • Field Detail

      • SUPPORTED

        private static final boolean SUPPORTED
    • Constructor Detail

      • CleanerJava24Linker

        public CleanerJava24Linker()
    • Method Detail

      • isSupported

        static boolean isSupported()
      • freeDirectBuffer

        public void freeDirectBuffer​(java.nio.ByteBuffer buffer)
        Description copied from interface: Cleaner
        Free a direct ByteBuffer if possible
        Specified by:
        freeDirectBuffer in interface Cleaner
      • hasExpensiveClean

        public boolean hasExpensiveClean()
        Description copied from interface: Cleaner
        Check if the clean operation is "relatively expensive". Expensive clean operations are fine for pooling allocators, but should be avoided for unpooled buffers.
        Specified by:
        hasExpensiveClean in interface Cleaner
        Returns:
        true if this Cleaner has an expensive clean (i.e. CleanableDirectBuffer.clean()) operation.
      • malloc

        static long malloc​(int capacity)
      • free

        static void free​(long memoryAddress)