public class JEmalloc
extends java.lang.Object
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
JEmalloc.Functions
Contains the function pointers loaded from the jemalloc
SharedLibrary. |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
JEMALLOC_VERSION
The version string.
|
static int |
JEMALLOC_VERSION_BUGFIX
The bugfix version.
|
static java.lang.String |
JEMALLOC_VERSION_GID
The globally unique identifier (git commit hash).
|
static int |
JEMALLOC_VERSION_MAJOR
The major version.
|
static int |
JEMALLOC_VERSION_MINOR
The minor version.
|
static int |
JEMALLOC_VERSION_NREV
The revision number.
|
static int |
MALLCTL_ARENAS_ALL
Use as arena index in "arena.<i>.{purge,decay,dss}" and "stats.arenas.<i>.*" mallctl interfaces to select all arenas.
|
static int |
MALLCTL_ARENAS_DESTROYED
Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select destroyed arenas.
|
static int |
MALLOCX_TCACHE_NONE
Do not use a thread-specific cache (tcache).
|
static int |
MALLOCX_ZERO
Initialize newly allocated memory to contain zero bytes.
|
| Modifier and Type | Method and Description |
|---|---|
static org.lwjgl.system.SharedLibrary |
getLibrary()
Returns the jemalloc
SharedLibrary. |
static java.nio.ByteBuffer |
je_aligned_alloc(long alignment,
long size)
Allocates
size bytes of memory such that the allocation's base address is an even multiple of alignment. |
static java.nio.ByteBuffer |
je_calloc(long num,
long size)
Allocates space for
num objects, each size bytes in length. |
static void |
je_dallocx(java.nio.ByteBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_dallocx(java.nio.DoubleBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_dallocx(java.nio.FloatBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_dallocx(java.nio.IntBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_dallocx(java.nio.LongBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_dallocx(org.lwjgl.PointerBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_dallocx(java.nio.ShortBuffer ptr,
int flags)
Causes the memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(java.nio.ByteBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(java.nio.DoubleBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(java.nio.FloatBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(java.nio.IntBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(java.nio.LongBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(org.lwjgl.PointerBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static void |
je_free(java.nio.ShortBuffer ptr)
Causes the allocated memory referenced by
ptr to be made available for future allocations. |
static int |
je_mallctl(java.nio.ByteBuffer name,
java.nio.ByteBuffer oldp,
org.lwjgl.PointerBuffer oldlenp,
java.nio.ByteBuffer newp)
Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.
|
static int |
je_mallctl(java.lang.CharSequence name,
java.nio.ByteBuffer oldp,
org.lwjgl.PointerBuffer oldlenp,
java.nio.ByteBuffer newp)
Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.
|
static int |
je_mallctlbymib(org.lwjgl.PointerBuffer mib,
java.nio.ByteBuffer oldp,
org.lwjgl.PointerBuffer oldlenp,
java.nio.ByteBuffer newp)
Similar to
mallctl, but uses MIBs instead of names. |
static int |
je_mallctlnametomib(java.nio.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 to
mallctlbymib. |
static int |
je_mallctlnametomib(java.lang.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 to
mallctlbymib. |
static org.lwjgl.PointerBuffer |
je_malloc_message()
Returns the
je_malloc_message variable. |
static void |
je_malloc_stats_print(MallocMessageCallbackI write_cb,
long cbopaque,
java.nio.ByteBuffer opts)
Writes human-readable summary statistics via the
write_cb callback function pointer and cbopaque data passed to write_cb, or
malloc_message() if write_cb is NULL. |
static void |
je_malloc_stats_print(MallocMessageCallbackI write_cb,
long cbopaque,
java.lang.CharSequence opts)
Writes human-readable summary statistics via the
write_cb callback function pointer and cbopaque data passed to write_cb, or
malloc_message() if write_cb is NULL. |
static long |
je_malloc_usable_size(java.nio.ByteBuffer ptr)
Returns the usable size of the allocation pointed to by
ptr. |
static java.nio.ByteBuffer |
je_malloc(long size)
Allocates
size bytes of uninitialized memory. |
static java.nio.ByteBuffer |
je_mallocx(long size,
int flags)
Allocates at least
size bytes of memory, and returns a pointer to the base address of the allocation. |
static java.nio.ByteBuffer |
je_nallocx(long size,
int flags)
Allocates no memory, but it performs the same size computation as the
mallocx function, and returns the real size of the allocation that would
result from the equivalent mallocx() function call. |
static int |
je_posix_memalign(org.lwjgl.PointerBuffer memptr,
long alignment,
long size)
Allocates
size bytes of memory such that the allocation's base address is an even multiple of alignment, and returns the allocation in
the value pointed to by memptr. |
static java.nio.ByteBuffer |
je_rallocx(java.nio.ByteBuffer ptr,
long size,
int flags)
Resizes the allocation at
ptr to be at least size bytes, and returns a pointer to the base address of the resulting allocation, which
may or may not have moved from its original location. |
static java.nio.ByteBuffer |
je_realloc(java.nio.ByteBuffer ptr,
long size)
Changes the size of the previously allocated memory referenced by
ptr to size bytes. |
static long |
je_sallocx(java.nio.ByteBuffer ptr,
int flags)
Returns the real size of the allocation at
ptr. |
static void |
je_sdallocx(java.nio.ByteBuffer ptr,
int flags)
Sized version of
dallocx. |
static void |
je_sdallocx(java.nio.DoubleBuffer ptr,
int flags)
Sized version of
dallocx. |
static void |
je_sdallocx(java.nio.FloatBuffer ptr,
int flags)
Sized version of
dallocx. |
static void |
je_sdallocx(java.nio.IntBuffer ptr,
int flags)
Sized version of
dallocx. |
static void |
je_sdallocx(java.nio.LongBuffer ptr,
int flags)
Sized version of
dallocx. |
static void |
je_sdallocx(org.lwjgl.PointerBuffer ptr,
int flags)
Sized version of
dallocx. |
static void |
je_sdallocx(java.nio.ShortBuffer ptr,
int flags)
Sized version of
dallocx. |
static long |
je_xallocx(java.nio.ByteBuffer ptr,
long size,
long extra,
int flags)
Resizes the allocation at
ptr in place to be at least size bytes, and returns the real size of the allocation. |
static int |
MALLOCX_ALIGN(int a)
Align the memory allocation to start at an address that is a multiple of
a, where a is a power of two. |
static int |
MALLOCX_ARENA(int a)
Use the arena specified by the index
a (and by necessity bypass the thread cache). |
static int |
MALLOCX_LG_ALIGN(int la)
Align the memory allocation to start at an address that is a multiple of
(1 << la). |
static int |
MALLOCX_TCACHE(int tc)
Use the thread-specific cache (tcache) specified by the identifier
tc, which must have been acquired via the tcache.create mallctl. |
static long |
nje_aligned_alloc(long alignment,
long size)
Unsafe version of:
aligned_alloc |
static long |
nje_calloc(long num,
long size)
Unsafe version of:
calloc |
static void |
nje_dallocx(long ptr,
int flags)
Unsafe version of:
dallocx |
static void |
nje_free(long ptr)
Unsafe version of:
free |
static int |
nje_mallctl(long name,
long oldp,
long oldlenp,
long newp,
long newlen)
Unsafe version of:
mallctl |
static int |
nje_mallctlbymib(long mib,
long miblen,
long oldp,
long oldlenp,
long newp,
long newlen)
Unsafe version of:
mallctlbymib |
static int |
nje_mallctlnametomib(long name,
long mibp,
long miblenp)
Unsafe version of:
mallctlnametomib |
static void |
nje_malloc_stats_print(long write_cb,
long cbopaque,
long opts)
Unsafe version of:
malloc_stats_print |
static long |
nje_malloc_usable_size(long ptr)
Unsafe version of:
malloc_usable_size |
static long |
nje_malloc(long size)
Unsafe version of:
malloc |
static long |
nje_mallocx(long size,
int flags)
Unsafe version of:
mallocx |
static long |
nje_nallocx(long size,
int flags)
Unsafe version of:
nallocx |
static int |
nje_posix_memalign(long memptr,
long alignment,
long size)
Unsafe version of:
posix_memalign |
static long |
nje_rallocx(long ptr,
long size,
int flags)
Unsafe version of:
rallocx |
static long |
nje_realloc(long ptr,
long size)
Unsafe version of:
realloc |
static long |
nje_sallocx(long ptr,
int flags)
Unsafe version of:
sallocx |
static void |
nje_sdallocx(long ptr,
long size,
int flags)
Unsafe version of:
sdallocx |
static long |
nje_xallocx(long ptr,
long size,
long extra,
int flags)
Unsafe version of:
xallocx |
public static final int JEMALLOC_VERSION_MAJOR
public static final int JEMALLOC_VERSION_MINOR
public static final int JEMALLOC_VERSION_BUGFIX
public static final int JEMALLOC_VERSION_NREV
public static final java.lang.String JEMALLOC_VERSION_GID
public static final java.lang.String JEMALLOC_VERSION
public static final int MALLOCX_ZERO
public static final int MALLOCX_TCACHE_NONE
MALLOCX_TCACHE(int) or MALLOCX_TCACHE_NONE is specified, an automatically managed
tcache will be used under many circumstances. This macro cannot be used in the same flags argument as MALLOCX_TCACHE(tc).public static final int MALLCTL_ARENAS_ALL
public static final int MALLCTL_ARENAS_DESTROYED
public static org.lwjgl.system.SharedLibrary getLibrary()
SharedLibrary.public static org.lwjgl.PointerBuffer je_malloc_message()
je_malloc_message variable.public static long nje_malloc(long size)
malloc@Nullable public static java.nio.ByteBuffer je_malloc(long size)
size bytes of uninitialized memory. The allocated space is suitably aligned (after possible pointer coercion) for storage of any type
of object.size - the number of bytes to allocatepublic static long nje_calloc(long num,
long size)
calloc@Nullable
public static java.nio.ByteBuffer je_calloc(long num,
long size)
num objects, each size bytes in length. The result is identical to calling malloc with an argument of
num * size, with the exception that the allocated memory is explicitly initialized to zero bytes.num - the number of objects to allocatesize - the size of each object, in bytespublic static int nje_posix_memalign(long memptr,
long alignment,
long size)
posix_memalignpublic static int je_posix_memalign(org.lwjgl.PointerBuffer memptr,
long alignment,
long size)
size bytes of memory such that the allocation's base address is an even multiple of alignment, and returns the allocation in
the value pointed to by memptr. The requested alignment must be a power of 2 at least as large as sizeof(void *).memptr - returns the allocated memoryalignment - the allocation alignment, in bytessize - the number of bytes to allocatepublic static long nje_aligned_alloc(long alignment,
long size)
aligned_alloc@Nullable
public static java.nio.ByteBuffer je_aligned_alloc(long alignment,
long size)
size bytes of memory such that the allocation's base address is an even multiple of alignment. The requested alignment must
be a power of 2. Behavior is undefined if size is not an integral multiple of alignment.alignment - the allocation alignment, in bytessize - the number of bytes to allocatepublic static long nje_realloc(long ptr,
long size)
realloc@Nullable
public static java.nio.ByteBuffer je_realloc(@Nullable
java.nio.ByteBuffer ptr,
long size)
ptr to size bytes. 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 by ptr is 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 than ptr. If ptr is NULL, the realloc() function behaves identically to malloc() for the
specified size.ptr - the previously allocated memory or NULLsize - the number of bytes to allocatepublic static void nje_free(long ptr)
freepublic static void je_free(@Nullable
java.nio.ByteBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static void je_free(@Nullable
java.nio.ShortBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static void je_free(@Nullable
java.nio.IntBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static void je_free(@Nullable
java.nio.LongBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static void je_free(@Nullable
java.nio.FloatBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static void je_free(@Nullable
java.nio.DoubleBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static void je_free(@Nullable
org.lwjgl.PointerBuffer ptr)
ptr to be made available for future allocations. If ptr is NULL, no action occurs.ptr - the allocated memory to freepublic static long nje_mallocx(long size,
int flags)
mallocx@Nullable
public static java.nio.ByteBuffer je_mallocx(long size,
int flags)
size bytes of memory, and returns a pointer to the base address of the allocation. Behavior is undefined if size is
0, or if request size overflows due to size class and/or alignment constraints.size - the number of bytes to allocateflags - a bitfield of zero or more of the MALLOCX macrospublic static long nje_rallocx(long ptr,
long size,
int flags)
rallocx@Nullable
public static java.nio.ByteBuffer je_rallocx(@Nullable
java.nio.ByteBuffer ptr,
long size,
int flags)
ptr to be at least size bytes, 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 if size is 0, or if request size overflows due to size class and/or
alignment constraints.ptr - the previously allocated memory or NULLsize - the number of bytes to allocateflags - a bitfield of zero or more of the MALLOCX macrospublic static long nje_xallocx(long ptr,
long size,
long extra,
int flags)
xallocxpublic static long je_xallocx(@Nullable
java.nio.ByteBuffer ptr,
long size,
long extra,
int flags)
ptr in place to be at least size bytes, and returns the real size of the allocation. If extra is 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 if size is 0, or if (size + extra > SIZE_T_MAX).ptr - the previously allocated memory or NULLsize - the number of bytes to allocateextra - the number of extra bytes to allocateflags - a bitfield of zero or more of the MALLOCX macrospublic static long nje_sallocx(long ptr,
int flags)
sallocxpublic static long je_sallocx(java.nio.ByteBuffer ptr,
int flags)
ptr.ptr - the allocated memory to queryflags - a bitfield of zero or more of the MALLOCX macrospublic static void nje_dallocx(long ptr,
int flags)
dallocxpublic static void je_dallocx(java.nio.ByteBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_dallocx(java.nio.ShortBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_dallocx(java.nio.IntBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_dallocx(java.nio.LongBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_dallocx(java.nio.FloatBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_dallocx(java.nio.DoubleBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_dallocx(org.lwjgl.PointerBuffer ptr,
int flags)
ptr to be made available for future allocations.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void nje_sdallocx(long ptr,
long size,
int flags)
sdallocxsize - the number of bytes in ptrpublic static void je_sdallocx(java.nio.ByteBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_sdallocx(java.nio.ShortBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_sdallocx(java.nio.IntBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_sdallocx(java.nio.LongBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_sdallocx(java.nio.FloatBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_sdallocx(java.nio.DoubleBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static void je_sdallocx(org.lwjgl.PointerBuffer ptr,
int flags)
dallocx. The primary optimization over dallocx() is the removal of a metadata read, which often suffers an L1 cache miss.ptr - the allocated memory to deallocateflags - a bitfield of zero or more of the MALLOCX macrospublic static long nje_nallocx(long size,
int flags)
nallocx@Nullable
public static java.nio.ByteBuffer je_nallocx(long size,
int flags)
mallocx function, and returns the real size of the allocation that would
result from the equivalent mallocx() function call. Behavior is undefined if size is 0, or if request size overflows due to size class
and/or alignment constraints.size - the number of bytes to allocateflags - a bitfield of zero or more of the MALLOCX macrospublic static int nje_mallctl(long name,
long oldp,
long oldlenp,
long newp,
long newlen)
mallctlnewlen - the new value lengthpublic static int je_mallctl(java.nio.ByteBuffer name,
@Nullable
java.nio.ByteBuffer oldp,
@Nullable
org.lwjgl.PointerBuffer oldlenp,
@Nullable
java.nio.ByteBuffer newp)
name argument 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 via oldp to adequate space to contain the value, and a pointer to its
length via oldlenp; otherwise pass NULL and NULL. Similarly, to write a value, pass a pointer to the value via newp, and its length
via newlen; otherwise pass NULL and 0.name - the namespace locationoldp - returns a valueoldlenp - returns the value lengthnewp - the new valuepublic static int je_mallctl(java.lang.CharSequence name,
@Nullable
java.nio.ByteBuffer oldp,
@Nullable
org.lwjgl.PointerBuffer oldlenp,
@Nullable
java.nio.ByteBuffer newp)
name argument 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 via oldp to adequate space to contain the value, and a pointer to its
length via oldlenp; otherwise pass NULL and NULL. Similarly, to write a value, pass a pointer to the value via newp, and its length
via newlen; otherwise pass NULL and 0.name - the namespace locationoldp - returns a valueoldlenp - returns the value lengthnewp - the new valuepublic static int nje_mallctlnametomib(long name,
long mibp,
long miblenp)
mallctlnametomibmiblenp - the number of components in mibppublic static int je_mallctlnametomib(java.nio.ByteBuffer name,
org.lwjgl.PointerBuffer mibp,
org.lwjgl.PointerBuffer miblenp)
mallctlbymib. Upon successful return from mallctlnametomib(),
mibp contains an array of *miblenp integers, where *miblenp is the lesser of the number of components in name and the input
value of *miblenp. Thus it is possible to pass a *miblenp that 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...
}name - the namespace locationmibp - an array of integersmiblenp - the number of components in mibppublic static int je_mallctlnametomib(java.lang.CharSequence name,
org.lwjgl.PointerBuffer mibp,
org.lwjgl.PointerBuffer miblenp)
mallctlbymib. Upon successful return from mallctlnametomib(),
mibp contains an array of *miblenp integers, where *miblenp is the lesser of the number of components in name and the input
value of *miblenp. Thus it is possible to pass a *miblenp that 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...
}name - the namespace locationmibp - an array of integersmiblenp - the number of components in mibppublic static int nje_mallctlbymib(long mib,
long miblen,
long oldp,
long oldlenp,
long newp,
long newlen)
mallctlbymibmiblen - the number of elements in mibnewlen - the new value lengthpublic static int je_mallctlbymib(org.lwjgl.PointerBuffer mib,
@Nullable
java.nio.ByteBuffer oldp,
@Nullable
org.lwjgl.PointerBuffer oldlenp,
@Nullable
java.nio.ByteBuffer newp)
mallctl, but uses MIBs instead of names. See mallctlnametomib for details.mib - a MIBoldp - returns a valueoldlenp - returns the value lengthnewp - the new valuepublic static void nje_malloc_stats_print(long write_cb,
long cbopaque,
long opts)
malloc_stats_printpublic static void je_malloc_stats_print(@Nullable
MallocMessageCallbackI write_cb,
long cbopaque,
@Nullable
java.nio.ByteBuffer opts)
write_cb callback function pointer and cbopaque data passed to write_cb, or
malloc_message() if write_cb is NULL. This function can be called repeatedly. General information that never changes during execution
can be omitted by specifying "g" as a character within the opts string. Note that malloc_message() uses the mallctl*()
functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously. If --enable-stats is
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.write_cb - the print callback, or NULL to use malloc_message()cbopaque - an opaque pointer that will be passed to write_cbopts - an options stringpublic static void je_malloc_stats_print(@Nullable
MallocMessageCallbackI write_cb,
long cbopaque,
@Nullable
java.lang.CharSequence opts)
write_cb callback function pointer and cbopaque data passed to write_cb, or
malloc_message() if write_cb is NULL. This function can be called repeatedly. General information that never changes during execution
can be omitted by specifying "g" as a character within the opts string. Note that malloc_message() uses the mallctl*()
functions internally, so inconsistent statistics can be reported if multiple threads use these functions simultaneously. If --enable-stats is
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.write_cb - the print callback, or NULL to use malloc_message()cbopaque - an opaque pointer that will be passed to write_cbopts - an options stringpublic static long nje_malloc_usable_size(long ptr)
malloc_usable_sizepublic static long je_malloc_usable_size(java.nio.ByteBuffer ptr)
ptr. The return value may be larger than the size that was requested during allocation.
The malloc_usable_size() function is not a mechanism for in-place realloc; rather it is provided solely as a tool for introspection
purposes. Any discrepancy between the requested allocation size and the size reported by malloc_usable_size() should not be depended on, since
such behavior is entirely implementation-dependent.ptr - the allocated memory to querypublic static int MALLOCX_LG_ALIGN(int la)
(1 << la). This macro does not validate that la is within the
valid range.la - the alignment shiftpublic static int MALLOCX_ALIGN(int a)
a, where a is a power of two. This macro does not validate
that a is a power of 2.a - the alignmentpublic static int MALLOCX_TCACHE(int tc)
tc, which must have been acquired via the tcache.create mallctl.
This macro does not validate that tc specifies a valid identifier.tc - the thread-specific cachepublic static int MALLOCX_ARENA(int a)
a (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 that a specifies an arena index in the valid range.a - the arena indexCopyright LWJGL. All Rights Reserved. License terms.