Class JEmalloc
jemalloc is a general purpose malloc implementation that emphasizes fragmentation avoidance and scalable concurrency support. jemalloc first came into use as the FreeBSD libc allocator in 2005, and since then it has found its way into numerous applications that rely on its predictable behavior. In 2010 jemalloc development efforts broadened to include developer support features such as heap profiling, Valgrind integration, and extensive monitoring/tuning hooks. Modern jemalloc releases continue to be integrated back into FreeBSD, and therefore versatility remains critical. Ongoing development efforts trend toward making jemalloc among the best allocators for a broad range of demanding applications, and eliminating/mitigating weaknesses that have practical repercussions for real world applications.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classContains the function pointers loaded from the jemallocSharedLibrary. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe version string.static final intThe bugfix version.static final StringThe globally unique identifier (git commit hash).static final intThe major version.static final intThe minor version.static final intThe revision number.static final intUse as arena index in "arena.<i>.{purge,decay,dss}" and "stats.arenas.<i>.*" mallctl interfaces to select all arenas.static final intUse as arena index in "stats.arenas.<i>.*" mallctl interfaces to select destroyed arenas.static final intDo not use a thread-specific cache (tcache).static final intInitialize newly allocated memory to contain zero bytes. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.lwjgl.system.SharedLibraryReturns the jemallocSharedLibrary.static @Nullable ByteBufferje_aligned_alloc(long alignment, long size) Allocatessizebytes of memory such that the allocation's base address is an even multiple ofalignment.static @Nullable ByteBufferje_calloc(long num, long size) Allocates space fornumobjects, eachsizebytes in length.static voidje_dallocx(ByteBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_dallocx(DoubleBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_dallocx(FloatBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_dallocx(IntBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_dallocx(LongBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_dallocx(ShortBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_dallocx(org.lwjgl.PointerBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.static voidje_free(@Nullable ByteBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations.static voidje_free(@Nullable DoubleBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations.static voidje_free(@Nullable FloatBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations.static voidCauses the allocated memory referenced byptrto be made available for future allocations.static voidje_free(@Nullable LongBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations.static voidje_free(@Nullable ShortBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations.static voidje_free(@Nullable org.lwjgl.PointerBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable ByteBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable DoubleBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable FloatBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable IntBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable LongBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable ShortBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_aligned_sized(@Nullable org.lwjgl.PointerBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations.static voidje_free_sized(@Nullable ByteBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static voidje_free_sized(@Nullable DoubleBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static voidje_free_sized(@Nullable FloatBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static voidje_free_sized(@Nullable IntBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static voidje_free_sized(@Nullable LongBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static voidje_free_sized(@Nullable ShortBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static voidje_free_sized(@Nullable org.lwjgl.PointerBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization.static intje_mallctl(CharSequence name, @Nullable ByteBuffer oldp, @Nullable org.lwjgl.PointerBuffer oldlenp, @Nullable ByteBuffer newp) Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.static intje_mallctl(ByteBuffer name, @Nullable ByteBuffer oldp, @Nullable org.lwjgl.PointerBuffer oldlenp, @Nullable ByteBuffer newp) Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.static intje_mallctlbymib(org.lwjgl.PointerBuffer mib, @Nullable ByteBuffer oldp, @Nullable org.lwjgl.PointerBuffer oldlenp, @Nullable ByteBuffer newp) Similar tomallctl, but uses MIBs instead of names.static intje_mallctlnametomib(CharSequence name, org.lwjgl.PointerBuffer mibp, org.lwjgl.PointerBuffer miblenp) Provides a way to avoid repeated name lookups for applications that repeatedly query the same portion of the namespace, by translating a name to a “Management Information Base” (MIB) that can be passed repeatedly tomallctlbymib.static intje_mallctlnametomib(ByteBuffer name, org.lwjgl.PointerBuffer mibp, org.lwjgl.PointerBuffer miblenp) Provides a way to avoid repeated name lookups for applications that repeatedly query the same portion of the namespace, by translating a name to a “Management Information Base” (MIB) that can be passed repeatedly tomallctlbymib.static @Nullable ByteBufferje_malloc(long size) Allocatessizebytes of uninitialized memory.static org.lwjgl.PointerBufferReturns theje_malloc_messagevariable.static voidje_malloc_stats_print(@Nullable MallocMessageCallbackI write_cb, long cbopaque, @Nullable CharSequence opts) Writes human-readable summary statistics via thewrite_cbcallback function pointer andcbopaquedata passed towrite_cb, ormalloc_message()ifwrite_cbisNULL.static voidje_malloc_stats_print(@Nullable MallocMessageCallbackI write_cb, long cbopaque, @Nullable ByteBuffer opts) Writes human-readable summary statistics via thewrite_cbcallback function pointer andcbopaquedata passed towrite_cb, ormalloc_message()ifwrite_cbisNULL.static longReturns the usable size of the allocation pointed to byptr.static @Nullable ByteBufferje_mallocx(long size, int flags) Allocates at leastsizebytes of memory, and returns a pointer to the base address of the allocation.static @Nullable ByteBufferje_nallocx(long size, int flags) Allocates no memory, but it performs the same size computation as themallocxfunction, and returns the real size of the allocation that would result from the equivalentmallocx()function call.static intje_posix_memalign(org.lwjgl.PointerBuffer memptr, long alignment, long size) Allocatessizebytes of memory such that the allocation's base address is an even multiple ofalignment, and returns the allocation in the value pointed to bymemptr.static @Nullable ByteBufferje_rallocx(@Nullable ByteBuffer ptr, long size, int flags) Resizes the allocation atptrto be at leastsizebytes, and returns a pointer to the base address of the resulting allocation, which may or may not have moved from its original location.static @Nullable ByteBufferje_realloc(@Nullable ByteBuffer ptr, long size) Changes the size of the previously allocated memory referenced byptrtosizebytes.static longje_sallocx(ByteBuffer ptr, int flags) Returns the real size of the allocation atptr.static voidje_sdallocx(ByteBuffer ptr, int flags) Sized version ofdallocx.static voidje_sdallocx(DoubleBuffer ptr, int flags) Sized version ofdallocx.static voidje_sdallocx(FloatBuffer ptr, int flags) Sized version ofdallocx.static voidje_sdallocx(IntBuffer ptr, int flags) Sized version ofdallocx.static voidje_sdallocx(LongBuffer ptr, int flags) Sized version ofdallocx.static voidje_sdallocx(ShortBuffer ptr, int flags) Sized version ofdallocx.static voidje_sdallocx(org.lwjgl.PointerBuffer ptr, int flags) Sized version ofdallocx.static longje_xallocx(@Nullable ByteBuffer ptr, long size, long extra, int flags) Resizes the allocation atptrin place to be at least size bytes, and returns the real size of the allocation.static intMALLOCX_ALIGN(int a) Align the memory allocation to start at an address that is a multiple ofa, whereais a power of two.static intMALLOCX_ARENA(int a) Use the arena specified by the indexa(and by necessity bypass the thread cache).static intMALLOCX_LG_ALIGN(int la) Align the memory allocation to start at an address that is a multiple of(1 << la).static intMALLOCX_TCACHE(int tc) Use the thread-specific cache (tcache) specified by the identifiertc, which must have been acquired via thetcache.createmallctl.static longnje_aligned_alloc(long alignment, long size) Unsafe version of:aligned_allocstatic longnje_calloc(long num, long size) Unsafe version of:callocstatic voidnje_dallocx(long ptr, int flags) Unsafe version of:dallocxstatic voidnje_free(long ptr) Unsafe version of:freestatic voidnje_free_aligned_sized(long ptr, long alignment, long size) Unsafe version of:free_aligned_sizedstatic voidnje_free_sized(long ptr, long size) Unsafe version of:free_sizedstatic intnje_mallctl(long name, long oldp, long oldlenp, long newp, long newlen) Unsafe version of:mallctlstatic intnje_mallctlbymib(long mib, long miblen, long oldp, long oldlenp, long newp, long newlen) Unsafe version of:mallctlbymibstatic intnje_mallctlnametomib(long name, long mibp, long miblenp) Unsafe version of:mallctlnametomibstatic longnje_malloc(long size) Unsafe version of:mallocstatic voidnje_malloc_stats_print(long write_cb, long cbopaque, long opts) Unsafe version of:malloc_stats_printstatic longnje_malloc_usable_size(long ptr) Unsafe version of:malloc_usable_sizestatic longnje_mallocx(long size, int flags) Unsafe version of:mallocxstatic longnje_nallocx(long size, int flags) Unsafe version of:nallocxstatic intnje_posix_memalign(long memptr, long alignment, long size) Unsafe version of:posix_memalignstatic longnje_rallocx(long ptr, long size, int flags) Unsafe version of:rallocxstatic longnje_realloc(long ptr, long size) Unsafe version of:reallocstatic longnje_sallocx(long ptr, int flags) Unsafe version of:sallocxstatic voidnje_sdallocx(long ptr, long size, int flags) Unsafe version of:sdallocxstatic longnje_xallocx(long ptr, long size, long extra, int flags) Unsafe version of:xallocx
-
Field Details
-
JEMALLOC_VERSION_MAJOR
public static final int JEMALLOC_VERSION_MAJORThe major version.- See Also:
-
JEMALLOC_VERSION_MINOR
public static final int JEMALLOC_VERSION_MINORThe minor version.- See Also:
-
JEMALLOC_VERSION_BUGFIX
public static final int JEMALLOC_VERSION_BUGFIXThe bugfix version.- See Also:
-
JEMALLOC_VERSION_NREV
public static final int JEMALLOC_VERSION_NREVThe revision number.- See Also:
-
JEMALLOC_VERSION_GID
The globally unique identifier (git commit hash).- See Also:
-
JEMALLOC_VERSION
The version string.- See Also:
-
MALLOCX_ZERO
public static final int MALLOCX_ZEROInitialize newly allocated memory to contain zero bytes. In the growing reallocation case, the real size prior to reallocation defines the boundary between untouched bytes and those that are initialized to contain zero bytes. If this macro is absent, newly allocated memory is uninitialized.- See Also:
-
MALLOCX_TCACHE_NONE
public static final int MALLOCX_TCACHE_NONEDo not use a thread-specific cache (tcache). UnlessMALLOCX_TCACHE(int)orMALLOCX_TCACHE_NONEis specified, an automatically managed tcache will be used under many circumstances. This macro cannot be used in the sameflagsargument asMALLOCX_TCACHE(tc). -
MALLCTL_ARENAS_ALL
public static final int MALLCTL_ARENAS_ALLUse as arena index in "arena.<i>.{purge,decay,dss}" and "stats.arenas.<i>.*" mallctl interfaces to select all arenas.- See Also:
-
MALLCTL_ARENAS_DESTROYED
public static final int MALLCTL_ARENAS_DESTROYEDUse as arena index in "stats.arenas.<i>.*" mallctl interfaces to select destroyed arenas.- See Also:
-
-
Method Details
-
getLibrary
public static org.lwjgl.system.SharedLibrary getLibrary()Returns the jemallocSharedLibrary. -
je_malloc_message
public static org.lwjgl.PointerBuffer je_malloc_message()Returns theje_malloc_messagevariable. -
nje_malloc
public static long nje_malloc(long size) Unsafe version of:malloc -
je_malloc
Allocatessizebytes of uninitialized memory. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object.- Parameters:
size- the number of bytes to allocate
-
nje_calloc
public static long nje_calloc(long num, long size) Unsafe version of:calloc -
je_calloc
Allocates space fornumobjects, eachsizebytes in length. The result is identical to callingmallocwith an argument ofnum * size, with the exception that the allocated memory is explicitly initialized to zero bytes.- Parameters:
num- the number of objects to allocatesize- the size of each object, in bytes
-
nje_posix_memalign
public static int nje_posix_memalign(long memptr, long alignment, long size) Unsafe version of:posix_memalign -
je_posix_memalign
public static int je_posix_memalign(org.lwjgl.PointerBuffer memptr, long alignment, long size) Allocatessizebytes of memory such that the allocation's base address is an even multiple ofalignment, and returns the allocation in the value pointed to bymemptr. The requested alignment must be a power of 2 at least as large assizeof(void *).- Parameters:
memptr- returns the allocated memoryalignment- the allocation alignment, in bytessize- the number of bytes to allocate
-
nje_aligned_alloc
public static long nje_aligned_alloc(long alignment, long size) Unsafe version of:aligned_alloc -
je_aligned_alloc
Allocatessizebytes of memory such that the allocation's base address is an even multiple ofalignment. The requested alignment must be a power of 2. Behavior is undefined ifsizeis not an integral multiple ofalignment.- Parameters:
alignment- the allocation alignment, in bytessize- the number of bytes to allocate
-
nje_realloc
public static long nje_realloc(long ptr, long size) Unsafe version of:realloc -
je_realloc
Changes the size of the previously allocated memory referenced byptrtosizebytes. The contents of the memory are unchanged up to the lesser of the new and old sizes. If the new size is larger, the contents of the newly allocated portion of the memory are undefined. Upon success, the memory referenced byptris freed and a pointer to the newly allocated memory is returned. Note that realloc() may move the memory allocation, resulting in a different return value thanptr. IfptrisNULL, the realloc() function behaves identically to malloc() for the specified size.- Parameters:
ptr- the previously allocated memory orNULLsize- the number of bytes to allocate
-
nje_free
public static void nje_free(long ptr) Unsafe version of:free -
je_free
Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
je_free
Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
je_free
Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
je_free
Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
je_free
Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
je_free
Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
je_free
public static void je_free(@Nullable org.lwjgl.PointerBuffer ptr) Causes the allocated memory referenced byptrto be made available for future allocations. IfptrisNULL, no action occurs.- Parameters:
ptr- the allocated memory to free
-
nje_free_sized
public static void nje_free_sized(long ptr, long size) Unsafe version of:free_sized -
je_free_sized
Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
je_free_sized
Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
je_free_sized
Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
je_free_sized
Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
je_free_sized
Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
je_free_sized
Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
je_free_sized
public static void je_free_sized(@Nullable org.lwjgl.PointerBuffer ptr) Thefree_sized()function is an extension offreewith asizeparameter to allow the caller to pass in the allocation size as an optimization. -
nje_free_aligned_sized
public static void nje_free_aligned_sized(long ptr, long alignment, long size) Unsafe version of:free_aligned_sized -
je_free_aligned_sized
Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
je_free_aligned_sized
Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
je_free_aligned_sized
Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
je_free_aligned_sized
Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
je_free_aligned_sized
Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
je_free_aligned_sized
Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
je_free_aligned_sized
public static void je_free_aligned_sized(@Nullable org.lwjgl.PointerBuffer ptr, long alignment) Thefree_aligned_sized()function accepts aptrwhich was allocated with a requestedsizeandalignment, causing the allocated memory referenced byptrto be made available for future allocations. -
nje_mallocx
public static long nje_mallocx(long size, int flags) Unsafe version of:mallocx -
je_mallocx
Allocates at leastsizebytes of memory, and returns a pointer to the base address of the allocation. Behavior is undefined ifsizeis 0, or if request size overflows due to size class and/or alignment constraints.- Parameters:
size- the number of bytes to allocateflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_rallocx
public static long nje_rallocx(long ptr, long size, int flags) Unsafe version of:rallocx -
je_rallocx
Resizes the allocation atptrto be at leastsizebytes, and returns a pointer to the base address of the resulting allocation, which may or may not have moved from its original location. Behavior is undefined ifsizeis 0, or if request size overflows due to size class and/or alignment constraints.- Parameters:
ptr- the previously allocated memory orNULLsize- the number of bytes to allocateflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_xallocx
public static long nje_xallocx(long ptr, long size, long extra, int flags) Unsafe version of:xallocx -
je_xallocx
Resizes the allocation atptrin place to be at least size bytes, and returns the real size of the allocation. Ifextrais non-zero, an attempt is made to resize the allocation to be at least(size + extra)bytes, though inability to allocate the extra byte(s) will not by itself result in failure to resize. Behavior is undefined ifsizeis 0, or if(size + extra > SIZE_T_MAX).- Parameters:
ptr- the previously allocated memory orNULLsize- the number of bytes to allocateextra- the number of extra bytes to allocateflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_sallocx
public static long nje_sallocx(long ptr, int flags) Unsafe version of:sallocx -
je_sallocx
Returns the real size of the allocation atptr.- Parameters:
ptr- the allocated memory to queryflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_dallocx
public static void nje_dallocx(long ptr, int flags) Unsafe version of:dallocx -
je_dallocx
Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_dallocx
Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_dallocx
Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_dallocx
Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_dallocx
Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_dallocx
Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_dallocx
public static void je_dallocx(org.lwjgl.PointerBuffer ptr, int flags) Causes the memory referenced byptrto be made available for future allocations.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_sdallocx
public static void nje_sdallocx(long ptr, long size, int flags) Unsafe version of:sdallocx- Parameters:
size- the number of bytes inptr
-
je_sdallocx
Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_sdallocx
Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_sdallocx
Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_sdallocx
Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_sdallocx
Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_sdallocx
Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
je_sdallocx
public static void je_sdallocx(org.lwjgl.PointerBuffer ptr, int flags) Sized version ofdallocx. The primary optimization overdallocx()is the removal of a metadata read, which often suffers an L1 cache miss.- Parameters:
ptr- the allocated memory to deallocateflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_nallocx
public static long nje_nallocx(long size, int flags) Unsafe version of:nallocx -
je_nallocx
Allocates no memory, but it performs the same size computation as themallocxfunction, and returns the real size of the allocation that would result from the equivalentmallocx()function call. Behavior is undefined ifsizeis 0, or if request size overflows due to size class and/or alignment constraints.- Parameters:
size- the number of bytes to allocateflags- a bitfield of zero or more of theMALLOCXmacros
-
nje_mallctl
public static int nje_mallctl(long name, long oldp, long oldlenp, long newp, long newlen) Unsafe version of:mallctl- Parameters:
newlen- the new value length
-
je_mallctl
public static int je_mallctl(ByteBuffer name, @Nullable ByteBuffer oldp, @Nullable org.lwjgl.PointerBuffer oldlenp, @Nullable ByteBuffer newp) Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions. The period-separatednameargument specifies a location in a tree-structured namespace; see the MALLCTL NAMESPACE section for documentation on the tree contents. To read a value, pass a pointer viaoldpto adequate space to contain the value, and a pointer to its length viaoldlenp; otherwise passNULLandNULL. Similarly, to write a value, pass a pointer to the value vianewp, and its length vianewlen; otherwise passNULLand0.- Parameters:
name- the namespace locationoldp- returns a valueoldlenp- returns the value lengthnewp- the new value
-
je_mallctl
public static int je_mallctl(CharSequence name, @Nullable ByteBuffer oldp, @Nullable org.lwjgl.PointerBuffer oldlenp, @Nullable ByteBuffer newp) Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions. The period-separatednameargument specifies a location in a tree-structured namespace; see the MALLCTL NAMESPACE section for documentation on the tree contents. To read a value, pass a pointer viaoldpto adequate space to contain the value, and a pointer to its length viaoldlenp; otherwise passNULLandNULL. Similarly, to write a value, pass a pointer to the value vianewp, and its length vianewlen; otherwise passNULLand0.- Parameters:
name- the namespace locationoldp- returns a valueoldlenp- returns the value lengthnewp- the new value
-
nje_mallctlnametomib
public static int nje_mallctlnametomib(long name, long mibp, long miblenp) Unsafe version of:mallctlnametomib- Parameters:
miblenp- the number of components inmibp
-
je_mallctlnametomib
public static int je_mallctlnametomib(ByteBuffer name, org.lwjgl.PointerBuffer mibp, org.lwjgl.PointerBuffer miblenp) Provides a way to avoid repeated name lookups for applications that repeatedly query the same portion of the namespace, by translating a name to a “Management Information Base” (MIB) that can be passed repeatedly tomallctlbymib. Upon successful return frommallctlnametomib(),mibpcontains an array of*miblenpintegers, where*miblenpis the lesser of the number of components in name and the input value of*miblenp. Thus it is possible to pass a*miblenpthat is smaller than the number of period-separated name components, which results in a partial MIB that can be used as the basis for constructing a complete MIB. For name components that are integers (e.g. the 2 in "arenas.bin.2.size"), the corresponding MIB component will always be that integer. Therefore, it is legitimate to construct code like the following:unsigned nbins, i; size_t mib[4]; size_t len, miblen; len = sizeof(nbins); mallctl("arenas.nbins", &nbins, &len, NULL, 0); miblen = 4; mallctlnametomib("arenas.bin.0.size", mib, &miblen); for (i = 0; i < nbins; i++) { size_t bin_size; mib[2] = i; len = sizeof(bin_size); mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0); // Do something with bin_size... }- Parameters:
name- the namespace locationmibp- an array of integersmiblenp- the number of components inmibp
-
je_mallctlnametomib
public static int je_mallctlnametomib(CharSequence name, org.lwjgl.PointerBuffer mibp, org.lwjgl.PointerBuffer miblenp) Provides a way to avoid repeated name lookups for applications that repeatedly query the same portion of the namespace, by translating a name to a “Management Information Base” (MIB) that can be passed repeatedly tomallctlbymib. Upon successful return frommallctlnametomib(),mibpcontains an array of*miblenpintegers, where*miblenpis the lesser of the number of components in name and the input value of*miblenp. Thus it is possible to pass a*miblenpthat is smaller than the number of period-separated name components, which results in a partial MIB that can be used as the basis for constructing a complete MIB. For name components that are integers (e.g. the 2 in "arenas.bin.2.size"), the corresponding MIB component will always be that integer. Therefore, it is legitimate to construct code like the following:unsigned nbins, i; size_t mib[4]; size_t len, miblen; len = sizeof(nbins); mallctl("arenas.nbins", &nbins, &len, NULL, 0); miblen = 4; mallctlnametomib("arenas.bin.0.size", mib, &miblen); for (i = 0; i < nbins; i++) { size_t bin_size; mib[2] = i; len = sizeof(bin_size); mallctlbymib(mib, miblen, &bin_size, &len, NULL, 0); // Do something with bin_size... }- Parameters:
name- the namespace locationmibp- an array of integersmiblenp- the number of components inmibp
-
nje_mallctlbymib
public static int nje_mallctlbymib(long mib, long miblen, long oldp, long oldlenp, long newp, long newlen) Unsafe version of:mallctlbymib- Parameters:
miblen- the number of elements inmibnewlen- the new value length
-
je_mallctlbymib
public static int je_mallctlbymib(org.lwjgl.PointerBuffer mib, @Nullable ByteBuffer oldp, @Nullable org.lwjgl.PointerBuffer oldlenp, @Nullable ByteBuffer newp) Similar tomallctl, but uses MIBs instead of names. Seemallctlnametomibfor details.- Parameters:
mib- a MIBoldp- returns a valueoldlenp- returns the value lengthnewp- the new value
-
nje_malloc_stats_print
public static void nje_malloc_stats_print(long write_cb, long cbopaque, long opts) Unsafe version of:malloc_stats_print -
je_malloc_stats_print
public static void je_malloc_stats_print(@Nullable MallocMessageCallbackI write_cb, long cbopaque, @Nullable ByteBuffer opts) Writes human-readable summary statistics via thewrite_cbcallback function pointer andcbopaquedata passed towrite_cb, ormalloc_message()ifwrite_cbisNULL. This function can be called repeatedly. General information that never changes during execution can be omitted by specifying "g" as a character within theoptsstring. Note thatmalloc_message()uses themallctl*()functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously. If--enable-statsis specified during configuration, “m” and “a” can be specified to omit merged arena and per arena statistics, respectively; “b” and “l” can be specified to omit per size class statistics for bins and large objects, respectively. Unrecognized characters are silently ignored. Note that thread caching may prevent some statistics from being completely up to date, since extra locking would be required to merge counters that track thread cache operations.- Parameters:
write_cb- the print callback, orNULLto usemalloc_message()cbopaque- an opaque pointer that will be passed towrite_cbopts- an options string
-
je_malloc_stats_print
public static void je_malloc_stats_print(@Nullable MallocMessageCallbackI write_cb, long cbopaque, @Nullable CharSequence opts) Writes human-readable summary statistics via thewrite_cbcallback function pointer andcbopaquedata passed towrite_cb, ormalloc_message()ifwrite_cbisNULL. This function can be called repeatedly. General information that never changes during execution can be omitted by specifying "g" as a character within theoptsstring. Note thatmalloc_message()uses themallctl*()functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously. If--enable-statsis specified during configuration, “m” and “a” can be specified to omit merged arena and per arena statistics, respectively; “b” and “l” can be specified to omit per size class statistics for bins and large objects, respectively. Unrecognized characters are silently ignored. Note that thread caching may prevent some statistics from being completely up to date, since extra locking would be required to merge counters that track thread cache operations.- Parameters:
write_cb- the print callback, orNULLto usemalloc_message()cbopaque- an opaque pointer that will be passed towrite_cbopts- an options string
-
nje_malloc_usable_size
public static long nje_malloc_usable_size(long ptr) Unsafe version of:malloc_usable_size -
je_malloc_usable_size
Returns the usable size of the allocation pointed to byptr. The return value may be larger than the size that was requested during allocation. Themalloc_usable_size()function is not a mechanism for in-placerealloc; rather it is provided solely as a tool for introspection purposes. Any discrepancy between the requested allocation size and the size reported bymalloc_usable_size()should not be depended on, since such behavior is entirely implementation-dependent.- Parameters:
ptr- the allocated memory to query
-
MALLOCX_LG_ALIGN
public static int MALLOCX_LG_ALIGN(int la) Align the memory allocation to start at an address that is a multiple of(1 << la). This macro does not validate thatlais within the valid range.- Parameters:
la- the alignment shift
-
MALLOCX_ALIGN
public static int MALLOCX_ALIGN(int a) Align the memory allocation to start at an address that is a multiple ofa, whereais a power of two. This macro does not validate thatais a power of 2.- Parameters:
a- the alignment
-
MALLOCX_TCACHE
public static int MALLOCX_TCACHE(int tc) Use the thread-specific cache (tcache) specified by the identifiertc, which must have been acquired via thetcache.createmallctl. This macro does not validate thattcspecifies a valid identifier.- Parameters:
tc- the thread-specific cache
-
MALLOCX_ARENA
public static int MALLOCX_ARENA(int a) Use the arena specified by the indexa(and by necessity bypass the thread cache). This macro has no effect for huge regions, nor for regions that were allocated via an arena other than the one specified. This macro does not validate thataspecifies an arena index in the valid range.- Parameters:
a- the arena index
-