Package org.ngengine.platform
Interface NGEAllocator
-
public interface NGEAllocatorPlatform memory allocator. Returned buffers are runtime-managed; raw values are native addresses only whenrawAddressesAreNative()is true.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description longaddress(java.nio.ByteBuffer buffer)Returns a native base address when supported, otherwise an opaque handle.default longalignedAllocFunctionPointer()default longalignedFreeFunctionPointer()default voidbeforeAlloc(long size)java.nio.ByteBuffercalloc(int count, int size)default longcallocFunctionPointer()default longcallocRaw(long count, long size)voidfree(java.nio.ByteBuffer buffer)Attempt an eager cleanup if supported by the underlying implementation.default voidfreeAlignedRaw(long address)default voidfreeBuffer(java.nio.Buffer buffer)default longfreeFunctionPointer()default voidfreeRaw(long address)java.nio.ByteBuffermalloc(int size)java.nio.ByteBuffermallocAligned(int size, int alignment)default longmallocAlignedRaw(long alignment, long size)default longmallocFunctionPointer()Zero means this backend has no callable native function pointer.default longmallocRaw(long size)default voidnotifyGC()default booleanrawAddressesAreNative()True when raw values are memory addresses rather than allocator-local handles.java.nio.ByteBufferrealloc(java.nio.ByteBuffer buffer, int newSize)default longreallocFunctionPointer()default longreallocRaw(long address, long size)
-
-
-
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 tofreeRaw(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
ByteBufferbecomes 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 ignorenull
-
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()
-
-