Package org.lwjgl.system.rpmalloc
Class RPmalloc
- java.lang.Object
-
- org.lwjgl.system.rpmalloc.RPmalloc
-
public class RPmalloc extends java.lang.ObjectNative bindings to the rpmalloc library. rpmalloc is a public domain cross platform lock free thread caching 16-byte aligned memory allocator implemented in C.You are required to call these functions from your own code in order to initialize and finalize the allocator in your process and threads:
malloc_initialize: Call at process start to initialize the allocatormalloc_finalize: Call at process exit to finalize the allocatormalloc_thread_initialize: Call at each thread start to initialize the thread local data for the allocatormalloc_thread_finalize: Call at each thread exit to finalize and release thread cache back to global cache
Then simply use the
malloc/freeand the other malloc style replacement functions. Remember all allocations are 16-byte aligned, so no need to call the explicitmemalign/aligned_alloc/posix_memalignfunctions unless you need greater alignment, they are simply wrappers to make it easier to replace in existing code.
-
-
Field Summary
Fields Modifier and Type Field and Description static intRPMALLOC_NO_PRESERVEFlag toaligned_reallocto not preserve content in reallocation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static java.nio.ByteBufferrpaligned_alloc(long alignment, long size)static java.nio.ByteBufferrpaligned_realloc(java.nio.ByteBuffer ptr, long alignment, long size, int flags)static java.nio.ByteBufferrpcalloc(long num, long size)static voidrpfree(java.nio.ByteBuffer ptr)static voidrpfree(java.nio.DoubleBuffer ptr)static voidrpfree(java.nio.FloatBuffer ptr)static voidrpfree(java.nio.IntBuffer ptr)static voidrpfree(java.nio.LongBuffer ptr)static voidrpfree(org.lwjgl.PointerBuffer ptr)static voidrpfree(java.nio.ShortBuffer ptr)static voidrpmalloc_finalize()Call at process exit to finalize the allocator.static voidrpmalloc_global_statistics(RPmallocGlobalStatistics stats)static voidrpmalloc_initialize()Call at process start to initialize the allocator.static intrpmalloc_is_thread_initialized()static voidrpmalloc_thread_collect()static voidrpmalloc_thread_finalize()Call at each thread exit to finalize and release thread cache back to global cache.static voidrpmalloc_thread_initialize()Call at each thread start to initialize the thread local data for the allocator.static voidrpmalloc_thread_statistics(RPmallocThreadStatistics stats)static longrpmalloc_usable_size(java.nio.ByteBuffer ptr)static longrpmalloc_usable_size(java.nio.DoubleBuffer ptr)static longrpmalloc_usable_size(java.nio.FloatBuffer ptr)static longrpmalloc_usable_size(java.nio.IntBuffer ptr)static longrpmalloc_usable_size(java.nio.LongBuffer ptr)static longrpmalloc_usable_size(org.lwjgl.PointerBuffer ptr)static longrpmalloc_usable_size(java.nio.ShortBuffer ptr)static java.nio.ByteBufferrpmalloc(long size)static java.nio.ByteBufferrpmemalign(long alignment, long size)static intrpposix_memalign(org.lwjgl.PointerBuffer memptr, long alignment, long size)static java.nio.ByteBufferrprealloc(java.nio.ByteBuffer ptr, long size)
-
-
-
Field Detail
-
RPMALLOC_NO_PRESERVE
public static final int RPMALLOC_NO_PRESERVE
Flag toaligned_reallocto not preserve content in reallocation.- See Also:
- Constant Field Values
-
-
Method Detail
-
rpmalloc_initialize
public static void rpmalloc_initialize()
Call at process start to initialize the allocator.This function also calls
malloc_thread_initialize.
-
rpmalloc_finalize
public static void rpmalloc_finalize()
Call at process exit to finalize the allocator.
-
rpmalloc_thread_initialize
public static void rpmalloc_thread_initialize()
Call at each thread start to initialize the thread local data for the allocator.
-
rpmalloc_thread_finalize
public static void rpmalloc_thread_finalize()
Call at each thread exit to finalize and release thread cache back to global cache.
-
rpmalloc_thread_collect
public static void rpmalloc_thread_collect()
-
rpmalloc_is_thread_initialized
public static int rpmalloc_is_thread_initialized()
-
rpmalloc_thread_statistics
public static void rpmalloc_thread_statistics(RPmallocThreadStatistics stats)
-
rpmalloc_global_statistics
public static void rpmalloc_global_statistics(RPmallocGlobalStatistics stats)
-
rpmalloc
public static java.nio.ByteBuffer rpmalloc(long size)
-
rpfree
public static void rpfree(java.nio.ByteBuffer ptr)
-
rpfree
public static void rpfree(java.nio.ShortBuffer ptr)
-
rpfree
public static void rpfree(java.nio.IntBuffer ptr)
-
rpfree
public static void rpfree(java.nio.LongBuffer ptr)
-
rpfree
public static void rpfree(java.nio.FloatBuffer ptr)
-
rpfree
public static void rpfree(java.nio.DoubleBuffer ptr)
-
rpfree
public static void rpfree(org.lwjgl.PointerBuffer ptr)
-
rpcalloc
public static java.nio.ByteBuffer rpcalloc(long num, long size)
-
rprealloc
public static java.nio.ByteBuffer rprealloc(java.nio.ByteBuffer ptr, long size)
-
rpaligned_realloc
public static java.nio.ByteBuffer rpaligned_realloc(java.nio.ByteBuffer ptr, long alignment, long size, int flags)
-
rpaligned_alloc
public static java.nio.ByteBuffer rpaligned_alloc(long alignment, long size)
-
rpmemalign
public static java.nio.ByteBuffer rpmemalign(long alignment, long size)
-
rpposix_memalign
public static int rpposix_memalign(org.lwjgl.PointerBuffer memptr, long alignment, long size)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(java.nio.ByteBuffer ptr)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(java.nio.ShortBuffer ptr)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(java.nio.IntBuffer ptr)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(java.nio.LongBuffer ptr)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(java.nio.FloatBuffer ptr)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(java.nio.DoubleBuffer ptr)
-
rpmalloc_usable_size
public static long rpmalloc_usable_size(org.lwjgl.PointerBuffer ptr)
-
-