Expand description
The Mnemosyne high-performance memory allocator global interface.
Modules§
- counting
- Per-thread allocation counting for allocator-budget tests.
- mitigations
- Compile-time security mitigation bitmask constants.
- scratch
- Aligned scratch pool for temporary buffers.
Macros§
- aligned_
vec - Constructs an
AlignedVecfrom a literal list of elements.
Structs§
- Aligned
Buf - A stack-resident, fixed-capacity buffer holding up to
Nelements ofT. - Aligned
Vec - A growable buffer with guaranteed byte alignment for SIMD operations.
- BinSnapshot
- Per-size-class allocation statistics snapshot.
- BinStats
Window - A snapshot of bin stats taken at a fixed point in time.
- Branded
Block - A wrapper representing a heap block branded with a compile-time unique lifetime.
- Branded
Box - A uniquely owned, safe pointer to heap-allocated memory of type
Tfrom aHeap. - Branded
Cell - A GhostCell-style shared container allowing interior mutability.
- Branded
Vec - A dynamically growing array allocated from a
Heap. - Cuda
Device Backend - A memory backend allocating CUDA device memory.
- Cuda
Gddr Backend - A zero-sized device backend with an allocator-local GDDR pool identity.
- Cuda
HbmBackend - A zero-sized device backend with an allocator-local HBM pool identity.
- Cuda
Host Pinned Backend - A memory backend allocating CUDA page-locked (pinned) host memory.
- Cuda
Unified Backend - A zero-copy memory backend mapping memory blocks directly using CUDA managed memory.
- Drain
- A draining iterator returned by
AlignedVec::drain. - Fast
Path Cache Config - Configuration for fast-path caches.
- Fast
Path Cache Manager - Thread-local fast-path cache manager.
- Fast
Path Efficiency Metrics - Snapshot of fast-path cache efficiency metrics.
- Hardened
Policy - Zero-Sized Type (ZST) representing a hardened allocation policy with memory poisoning, zero-initialization, and free-list XOR encryption.
- Heap
- A scoped, lifetime-branded memory heap.
- Into
Iter - Consuming iterator that moves elements out of an
AlignedVec<T>. - Memory
Backend Wrapper - High-level OS page mapping backend helper. Owns the wrapper struct
shape and forwards the platform-conditional capability consts from
crate::DefaultBackend; per-method bodies delegate to per-concern helpers incrate::guardandcrate::reset. - Memory
Stats - Snapshot of Mnemosyne memory mapping and segment cache state.
- Mnemosyne
- The Mnemosyne global allocator structure.
- Mnemosyne
Allocator - Generic global allocator that is parameterized by an allocation policy
Pand a memory backendB. - Mnemosyne
Options - Runtime configuration options for the Mnemosyne allocator.
- Policy
Marker - Zero-sized type (ZST) that brands a data structure with the allocator
policy used to create it — zero runtime cost (
PhantomData<P>). - Realloc
Error - A failed branded reallocation that retains ownership of the source block.
- Scratch
Bank - A fixed set of same-typed scratch pools for domain-specific temporary roles.
- Scratch
Pool - A pool of reusable, aligned scratch buffers for a specific element type.
- Secure
Policy - Zero-Sized Type (ZST) representing a secure allocation policy with memory poisoning and zero-initialization.
- Size
Class Cache - Per-size-class cache for frequently-used allocation sizes.
- Size
Class Info - Bundles all the per-class constants that are computed separately in the individual lookup functions — convenient when a consumer needs multiple fields for the same class without repeated calls.
- Size
Class Occupancy - Occupancy counters for a single size class in the current thread allocator.
- Standard
Policy - Zero-Sized Type (ZST) representing the standard allocation policy with maximum performance.
- Sync
Region Token - A brand owner that is
Send + Syncand may be handed across thread boundaries to relocate exclusive write capability. - Thread
Local Token - A brand owner that is statically pinned to one thread.
Enums§
- Realloc
Failure - The reason a branded reallocation could not produce a replacement block.
Constants§
- DEFAULT_
SCRATCH_ ALIGN - Default alignment for scratch buffers (64 bytes = one AVX-512 cache line).
- LEMIRE_
DIV_ SHIFT - Shift constant for the Lemire indirect reciprocal.
- MAX_
POOL_ SLOTS - Maximum concurrent borrows (recursive/nested calls) the pool supports.
- NUM_
SIZE_ CLASSES - The total number of small size classes.
Traits§
- Alloc
Policy - A sealed trait representing an allocator behavior and safety policy.
- Local
Allocator Selector - Backend hook that supplies the thread-local allocator cache and mode-keyed selector entry points for a concrete segment pool backend. The backend-local thread allocator selection API.
- Scratch
Element - Element types that the scratch pool can manage.
Functions§
- all_
bin_ snapshots - Returns snapshots for all
NUM_SIZE_CLASSESsize classes. - all_
class_ info - Returns an iterator-compatible array of
SizeClassInfofor all classes. - alloc_
distribution - Returns the fractional distribution of
alloc_countacross all size classes as an array off64values in[0.0, 1.0]that sum to 1.0. - bin_
snapshot - Returns a snapshot for size class
class, orNoneif out of range. - block_
index_ in_ page - Block index within a page using Lemire reciprocal multiplication.
- branded_
scope - Executes a closure with a fresh, compile-time unique branded heap and token.
- class_
to_ max_ blocks - Maps a size class index to its maximum number of blocks in a page.
- class_
to_ size - Maps a size class index to its maximum block size.
- configure
- Configures the allocator runtime settings programmatically.
- decay
- Triggers a manual background decay and defragmentation cycle across all active memory backends.
- disable_
leak_ detector - Disables the built-in memory leak detector.
- disable_
profiling - Disables the built-in Poisson heap sampler.
- dump_
leaks - Dumps all active allocations (representing leaks) with their resolved stacks to a file.
- dump_
profile - Dumps a folded stack profile of active memory allocations to a file.
- enable_
leak_ detector - Enables the built-in memory leak detector, tracking every allocation with its backtrace.
- enable_
profiling - Enables the built-in Poisson heap sampler.
- flush_
tls_ stats - Flushes the calling thread’s pending bin-stats batch to the global counters.
- get_
options - Returns the current allocator configuration options snapshot.
- hottest_
class - Returns the index of the hottest size class (highest alloc_count), or
Nonewhen nothing has ever been allocated. - is_
cuda_ available - Returns true if the CUDA unified memory driver was successfully resolved.
- is_
leak_ detector_ enabled - Returns whether the memory leak detector is currently active.
- is_
profiling_ enabled - Returns whether the built-in heap sampler is currently active.
- memory_
stats - Returns current Mnemosyne allocator memory counters for the default
Mnemosyneallocator. - memory_
stats_ generic - Returns current Mnemosyne allocator memory counters for a specific policy and backend.
- memory_
stats_ json - Returns a JSON representation of the current memory statistics and
per-size-bin counters as an owned
String. - policy_
summary - Returns a human-readable one-line summary of the current policy and telemetry.
- purge
- Purges the global segment pool, releasing all retained/cached segments back to the OS.
- purge_
generic - Purges the global segment pool for a specific backend, releasing all retained/cached segments back to the OS.
- purge_
lazy - Purges the global segment pool while keeping
warm_thresholdcommitted segments ready for immediate reuse. - purge_
standard - Purges with
StandardPolicy::SEGMENT_POOL_WARM_THRESHOLDwarm segments kept. - register_
alloc_ hook - Registers a custom user allocation tracing hook.
- register_
free_ hook - Registers a custom user deallocation tracing hook.
- reset
- Asks the OS to drop the physical backing of every retained standard free segment without removing them from the cache.
- reset_
bin_ stats - Resets all per-class counters to zero.
- reset_
generation_ count - Returns the current value of the reset generation counter.
- reset_
generic - Asks the OS to drop the physical backing of every retained standard free segment for a specific backend without removing them from the cache.
- round_
up_ size_ saturating - Returns the class stride for the given request, saturating to the largest
class when
size > MAX_SMALL_ALLOC_SIZE. - size_
class_ fragmentation - Returns the internal fragmentation for a request of
sizebytes:(class_stride - size) / class_stride, in[0.0, 1.0]. - size_
to_ class - Maps an allocation size to its corresponding size class index.
- size_
to_ class_ nonzero - Maps a non-zero allocation size to its corresponding size class index.
- summary_
line - One-line human-readable summary of process-wide bin stats.
- sync_
scope - Executes a closure with a fresh, thread-portable branded heap and token.
- top_
n_ classes - Returns the
nhottest size classes by alloc_count, sorted descending. - total_
alloc_ count - Process-wide total allocation count across all small size classes.
- total_
internal_ fragmentation - Process-wide internal fragmentation ratio:
(total_alloc_bytes - total_requested_bytes) / total_alloc_bytes. - total_
live_ bytes - Process-wide live bytes in the small allocator: sum of
live_estimate × block_sizeacross all classes. - total_
requested_ bytes - Process-wide cumulative user-requested bytes across all small size classes.
- usable_
size ⚠ - Returns the actual usable byte count of the allocation at
ptr. - warm_
current_ thread - Forces the Mnemosyne thread-local allocator to initialize for the current
thread by performing a minimal allocation and deallocation through the
Mnemosyneallocator.
Type Aliases§
- Invariant
Lifetime - A zero-sized marker that is invariant in
'brandand unconditionallySend + Sync.