Interface NGEAllocator


  • public interface NGEAllocator
    A native memory allocator interface. ByteBuffers returned by this allocator are managed and the underlying memory will be reclaimed as soon as the ByteBuffer is garbage collected. They are also hardened against common memory safety issues.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long address​(java.nio.ByteBuffer buffer)  
      java.nio.ByteBuffer calloc​(int count, int size)  
      void free​(java.nio.ByteBuffer buffer)
      Attempt an eager cleanup if supported by the underlying implementation.
      java.nio.ByteBuffer malloc​(int size)  
      java.nio.ByteBuffer mallocAligned​(int size, int alignment)  
      java.nio.ByteBuffer realloc​(java.nio.ByteBuffer buffer, int newSize)  
    • Method Detail

      • malloc

        java.nio.ByteBuffer malloc​(int size)
      • calloc

        java.nio.ByteBuffer calloc​(int count,
                                   int size)
      • realloc

        java.nio.ByteBuffer realloc​(java.nio.ByteBuffer buffer,
                                    int newSize)
      • mallocAligned

        java.nio.ByteBuffer mallocAligned​(int size,
                                          int alignment)
      • address

        long address​(java.nio.ByteBuffer buffer)
      • free

        void free​(java.nio.ByteBuffer buffer)
        Attempt an eager cleanup if supported by the underlying implementation.

        This method is best-effort only. It may do nothing, depending on the runtime and allocator implementation. In normal usage, calling this method is usually unnecessary and not recommended, because the buffer's memory is reclaimed automatically when the ByteBuffer becomes unreachable and is garbage collected.

        Use this only in situations with significant memory pressure where an implementation may be able to reduce retained memory sooner.

        After calling this method, the provided buffer should not be used anymore

        Parameters:
        buffer - the buffer to release; implementations may ignore null