Interface NGEAllocator


  • public interface NGEAllocator
    Platform memory allocator. Returned buffers are runtime-managed; raw values are native addresses only when rawAddressesAreNative() is true.
    • 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)
        Returns a native base address when supported, otherwise an opaque handle. A buffer obtained through this API remains runtime-owned: its address must not be passed to freeRaw(long) on native-address backends.
      • 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
      • rawAddressesAreNative

        default boolean rawAddressesAreNative()
        True when raw values are memory addresses rather than allocator-local handles.
      • mallocRaw

        default long mallocRaw​(long size)
      • callocRaw

        default long callocRaw​(long count,
                               long size)
      • reallocRaw

        default long reallocRaw​(long address,
                                long size)
      • freeRaw

        default void freeRaw​(long address)
      • mallocAlignedRaw

        default long mallocAlignedRaw​(long alignment,
                                      long size)
      • freeAlignedRaw

        default void freeAlignedRaw​(long address)
      • mallocFunctionPointer

        default long mallocFunctionPointer()
        Zero means this backend has no callable native function pointer.
      • callocFunctionPointer

        default long callocFunctionPointer()
      • reallocFunctionPointer

        default long reallocFunctionPointer()
      • freeFunctionPointer

        default long freeFunctionPointer()
      • alignedAllocFunctionPointer

        default long alignedAllocFunctionPointer()
      • alignedFreeFunctionPointer

        default long alignedFreeFunctionPointer()
      • freeBuffer

        default void freeBuffer​(java.nio.Buffer buffer)
      • beforeAlloc

        default void beforeAlloc​(long size)
      • notifyGC

        default void notifyGC()