Package org.ngengine.platform
Interface NGEAllocator
-
public interface NGEAllocatorA 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 longaddress(java.nio.ByteBuffer buffer)java.nio.ByteBuffercalloc(int count, int size)voidfree(java.nio.ByteBuffer buffer)Attempt an eager cleanup if supported by the underlying implementation.java.nio.ByteBuffermalloc(int size)java.nio.ByteBuffermallocAligned(int size, int alignment)java.nio.ByteBufferrealloc(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
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
-
-