Expand description
Rust bindings to the jemalloc C library.
jemalloc is a general purpose memory allocation, its documentation
can be found here:
- API documentation
- Wiki (design documents, presentations, profiling, debugging, tuning, …)
jemalloc exposes both a standard and a non-standard API.
§Standard API
The standard API includes: the malloc, calloc, realloc, and
free, which conform to to ISO/IEC 9899:1990 (“ISO C90”),
posix_memalign which conforms to conforms to POSIX.1-2016, and
aligned_alloc.
Note that these standard leave some details as implementation defined.
This docs document this behavior for jemalloc, but keep in mind that other
standard-conforming implementations of these functions in other allocators
might behave slightly different.
§Non-Standard API
The non-standard API includes: mallocx, rallocx, xallocx,
sallocx, dallocx, sdallocx, and nallocx. These functions all
have a flags argument that can be used to specify options. Use bitwise or
| to specify one or more of the following: MALLOCX_LG_ALIGN,
MALLOCX_ALIGN, MALLOCX_ZERO, MALLOCX_TCACHE,
MALLOCX_TCACHE_NONE, and MALLOCX_ARENA.
§Environment variables
The MALLOC_CONF environment variable affects the execution of the allocation functions.
For the documentation of the MALLCTL namespace visit the jemalloc
documenation.
Structs§
- extent_
hooks_ s - Extent lifetime management functions.
Constants§
- MALLOCX_
TCACHE_ NONE - Do not use a thread-specific cache (tcache).
- MALLOCX_
ZERO - Initialize newly allocated memory to contain zero bytes.
Statics§
- NO_
BG_ THREAD_ TARGETS jemalloc’s background_thread support is known not to work on these targets:- NO_
UNPREFIXED_ MALLOC_ TARGETS - targets that don’t support unprefixed
malloc - UNSUPPORTED_
TARGETS jemallocis known not to work on these targets:- UNTESTED_
TARGETS jemalloc-sysis not tested on these targets in CI:- malloc_
conf ⚠ - Compile-time string of configuration options.
- malloc_
message ⚠ - Allows overriding the function which emits the text strings forming the
errors and warnings if for some reason the
STDERR_FILENOfile descriptor is not suitable for this.
Functions§
- MALLOCX_
ALIGN - Align the memory allocation to start at an address that is a multiple of
align, where a is a power of two. - MALLOCX_
ARENA - Use the arena specified by the index
a. - MALLOCX_
LG_ ALIGN - Align the memory allocation to start at an address that is a
multiple of
1 << la. - MALLOCX_
TCACHE - Use the thread-specific cache (tcache) specified by the identifier
tc. - aligned_
alloc ⚠ - Allocates
sizebytes of memory at an address which is a multiple ofalignment. - calloc⚠
- Allocates zero-initialized space for an array of
numberobjects, each of whose size issize. - dallocx⚠
- Deallocates previously-allocated memory region referenced by
ptr. - free⚠
- Deallocates previously-allocated memory region referenced by
ptr. - mallctl⚠
- General interface for introspecting the memory allocator, as well as setting modifiable parameters and triggering actions.
- mallctlbymib⚠
- Like
mallctlbut taking amibas input instead of a name. - mallctlnametomib⚠
- Translates a name to a “Management Information Base” (MIB) that can be
passed repeatedly to
mallctlbymib. - malloc⚠
- Allocates
sizebytes of uninitialized memory. - malloc_
stats_ ⚠print - Writes summary statistics via the
write_cbcallback function pointer andcbopaquedata passed towrite_cb, ormalloc_messageifwrite_cbis null. - malloc_
usable_ ⚠size - Returns the real size of the previously-allocated memory region
referenced by
ptr. - mallocx⚠
- Allocates at least
sizebytes of memory according toflags. - nallocx⚠
- Returns the real size of the allocation that would result from a
mallocxfunction call with the same arguments. - posix_
memalign ⚠ - Allocates
sizebytes of memory at an address which is a multiple ofalignmentand is placed in*ptr. - rallocx⚠
- Resizes the previously-allocated memory region referenced by
ptrto be at leastsizebytes. - realloc⚠
- Resizes the previously-allocated memory region referenced by
ptrtosizebytes. - sallocx⚠
- Returns the real size of the previously-allocated memory region
referenced by
ptr. - sdallocx⚠
- Deallocates previously-allocated memory region referenced by
ptrwithsizehint. - xallocx⚠
- Resizes the previously-allocated memory region referenced by
ptrin place to be at leastsizebytes, returning the real size of the allocation.
Type Aliases§
- extent_
alloc_ t - Extent allocation function.
- extent_
commit_ t - Extent commit function.
- extent_
dalloc_ t - Extent deallocation function.
- extent_
decommit_ t - Extent decommit function.
- extent_
destroy_ t - Extent destruction function.
- extent_
hooks_ t - Extent lifetime management functions.
- extent_
merge_ t - Extent merge function.
- extent_
purge_ t - Extent purge function.
- extent_
split_ t - Extent split function.