Top Description Inners Fields Constructors Methods
org.lwjgl.system.jemalloc

public Class JEmalloc

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.*, org.lwjgl.system.*

Native bindings to 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 and Inner Type Summary

Modifier and TypeClass and Description
public static class
JEmalloc.Functions

Contains the function pointers loaded from the jemalloc SharedLibrary.

Field Summary

Modifier and TypeField and Description
private static final SharedLibrary
public static final String
JEMALLOC_VERSION

The version string.

public static final int
JEMALLOC_VERSION_BUGFIX

The bugfix version.

public static final String
JEMALLOC_VERSION_GID

The globally unique identifier (git commit hash).

public static final int
JEMALLOC_VERSION_MAJOR

The major version.

public static final int
JEMALLOC_VERSION_MINOR

The minor version.

public static final int
JEMALLOC_VERSION_NREV

The revision number.

public static final int
MALLCTL_ARENAS_ALL

Use as arena index in "arena.

public static final int
MALLCTL_ARENAS_DESTROYED

Use as arena index in "stats.arenas.

public static final int
MALLOCX_TCACHE_NONE

Do not use a thread-specific cache (tcache).

public static final int
MALLOCX_ZERO

Initialize newly allocated memory to contain zero bytes.

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static SharedLibrary
getLibrary()

Returns the jemalloc SharedLibrary.

public static ByteBuffer
je_aligned_alloc(long
the allocation alignment, in bytes
alignment
,
long
the number of bytes to allocate
size
)

Allocates size bytes of memory such that the allocation's base address is an even multiple of alignment.

public static ByteBuffer
je_calloc(long
the number of objects to allocate
num
,
long
the size of each object, in bytes
size
)

Allocates space for num objects, each size bytes in length.

public static void
je_dallocx(ByteBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_dallocx(ShortBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_dallocx(IntBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_dallocx(LongBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_dallocx(FloatBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_dallocx(DoubleBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_dallocx(PointerBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Causes the memory referenced by ptr to be made available for future allocations.

public static void
je_free(ByteBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free(ShortBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free(IntBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free(LongBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free(FloatBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free(DoubleBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free(PointerBuffer
the allocated memory to free
ptr
)

Causes the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(ByteBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(ShortBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(IntBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(LongBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(FloatBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(DoubleBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_aligned_sized(PointerBuffer ptr, long alignment)

The free_aligned_sized() function accepts a ptr which was allocated with a requested size and alignment, causing the allocated memory referenced by ptr to be made available for future allocations.

public static void
je_free_sized(ByteBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static void
je_free_sized(ShortBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static void
je_free_sized(IntBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static void
je_free_sized(LongBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static void
je_free_sized(FloatBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static void
je_free_sized(DoubleBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static void
je_free_sized(PointerBuffer ptr)

The free_sized() function is an extension of free with a size parameter to allow the caller to pass in the allocation size as an optimization.

public static int
je_mallctl(ByteBuffer
the namespace location
name
,
ByteBuffer
returns a value
oldp
,
PointerBuffer
returns the value length
oldlenp
,
ByteBuffer
the new value
newp
)

Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.

public static int
je_mallctl(CharSequence
the namespace location
name
,
ByteBuffer
returns a value
oldp
,
PointerBuffer
returns the value length
oldlenp
,
ByteBuffer
the new value
newp
)

Provides a general interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.

public static int
je_mallctlbymib(PointerBuffer
a MIB
mib
,
ByteBuffer
returns a value
oldp
,
PointerBuffer
returns the value length
oldlenp
,
ByteBuffer
the new value
newp
)

Similar to mallctl, but uses MIBs instead of names.

public static int
je_mallctlnametomib(ByteBuffer
the namespace location
name
,
PointerBuffer
an array of integers
mibp
,
PointerBuffer
the number of components in mibp
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.

public static int
je_mallctlnametomib(CharSequence
the namespace location
name
,
PointerBuffer
an array of integers
mibp
,
PointerBuffer
the number of components in mibp
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.

public static ByteBuffer
je_malloc(long
the number of bytes to allocate
size
)

Allocates size bytes of uninitialized memory.

public static PointerBuffer
je_malloc_message()

Returns the je_malloc_message variable.

public static void
je_malloc_stats_print(MallocMessageCallbackI
the print callback, or NULL to use malloc_message()
write_cb
,
long
an opaque pointer that will be passed to write_cb
cbopaque
,
ByteBuffer
an options string
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.

public static void
je_malloc_stats_print(MallocMessageCallbackI
the print callback, or NULL to use malloc_message()
write_cb
,
long
an opaque pointer that will be passed to write_cb
cbopaque
,
CharSequence
an options string
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.

public static long
je_malloc_usable_size(ByteBuffer
the allocated memory to query
ptr
)

Returns the usable size of the allocation pointed to by ptr.

public static ByteBuffer
je_mallocx(long
the number of bytes to allocate
size
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Allocates at least size bytes of memory, and returns a pointer to the base address of the allocation.

public static ByteBuffer
je_nallocx(long
the number of bytes to allocate
size
,
int
a bitfield of zero or more of the MALLOCX macros
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.

public static int
je_posix_memalign(PointerBuffer
returns the allocated memory
memptr
,
long
the allocation alignment, in bytes
alignment
,
long
the number of bytes to allocate
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.

public static ByteBuffer
je_rallocx(ByteBuffer
the previously allocated memory or NULL
ptr
,
long
the number of bytes to allocate
size
,
int
a bitfield of zero or more of the MALLOCX macros
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.

public static ByteBuffer
je_realloc(ByteBuffer
the previously allocated memory or NULL
ptr
,
long
the number of bytes to allocate
size
)

Changes the size of the previously allocated memory referenced by ptr to size bytes.

public static long
je_sallocx(ByteBuffer
the allocated memory to query
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Returns the real size of the allocation at ptr.

public static void
je_sdallocx(ByteBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static void
je_sdallocx(ShortBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static void
je_sdallocx(IntBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static void
je_sdallocx(LongBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static void
je_sdallocx(FloatBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static void
je_sdallocx(DoubleBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static void
je_sdallocx(PointerBuffer
the allocated memory to deallocate
ptr
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Sized version of dallocx.

public static long
je_xallocx(ByteBuffer
the previously allocated memory or NULL
ptr
,
long
the number of bytes to allocate
size
,
long
the number of extra bytes to allocate
extra
,
int
a bitfield of zero or more of the MALLOCX macros
flags
)

Resizes the allocation at ptr in place to be at least size bytes, and returns the real size of the allocation.

public static int
MALLOCX_ALIGN(int
the alignment
a
)

Align the memory allocation to start at an address that is a multiple of a, where a is a power of two.

public static int
MALLOCX_ARENA(int
the arena index
a
)

Use the arena specified by the index a (and by necessity bypass the thread cache).

public static int
MALLOCX_LG_ALIGN(int
the alignment shift
la
)

Align the memory allocation to start at an address that is a multiple of (1 << la).

public static int
MALLOCX_TCACHE(int
the thread-specific cache
tc
)

Use the thread-specific cache (tcache) specified by the identifier tc, which must have been acquired via the tcache.create mallctl.

public static long
nje_aligned_alloc(long alignment, long size)

Unsafe version of: aligned_alloc

public static long
nje_calloc(long num, long size)

Unsafe version of: calloc

public static void
nje_dallocx(long ptr, int flags)

Unsafe version of: dallocx

public static void
nje_free(long ptr)

Unsafe version of: free

public static void
nje_free_aligned_sized(long ptr, long alignment, long size)

Unsafe version of: free_aligned_sized

public static void
nje_free_sized(long ptr, long size)

Unsafe version of: free_sized

public static int
nje_mallctl(long name, long oldp, long oldlenp, long newp, long
the new value length
newlen
)

Unsafe version of: mallctl

public static int
nje_mallctlbymib(long mib, long
the number of elements in mib
miblen
,
long oldp, long oldlenp, long newp, long
the new value length
newlen
)

Unsafe version of: mallctlbymib

public static int
nje_mallctlnametomib(long name, long mibp, long
the number of components in mibp
miblenp
)

Unsafe version of: mallctlnametomib

public static long
nje_malloc(long size)

Unsafe version of: malloc

public static void
nje_malloc_stats_print(long write_cb, long cbopaque, long opts)

Unsafe version of: malloc_stats_print

public static long
nje_malloc_usable_size(long ptr)

Unsafe version of: malloc_usable_size

public static long
nje_mallocx(long size, int flags)

Unsafe version of: mallocx

public static long
nje_nallocx(long size, int flags)

Unsafe version of: nallocx

public static int
nje_posix_memalign(long memptr, long alignment, long size)

Unsafe version of: posix_memalign

public static long
nje_rallocx(long ptr, long size, int flags)

Unsafe version of: rallocx

public static long
nje_realloc(long ptr, long size)

Unsafe version of: realloc

public static long
nje_sallocx(long ptr, int flags)

Unsafe version of: sallocx

public static void
nje_sdallocx(long ptr, long
the number of bytes in ptr
size
,
int flags)

Unsafe version of: sdallocx

public static long
nje_xallocx(long ptr, long size, long extra, int flags)

Unsafe version of: xallocx

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait