rustfs-mimalloc
High-performance mimalloc V3 global allocator for Rust.
Quick Start
[]
= "0.5.2"
use MiMalloc;
static GLOBAL: MiMalloc = MiMalloc;
Features
| Feature | Description |
|---|---|
secure |
Heap allocation encryption (MI_SECURE=4) |
debug |
mimalloc debug checks |
debug_in_debug |
Auto-enable debug in Cargo debug builds |
override |
Override system malloc/free |
local_dynamic_tls |
Use local-dynamic TLS model |
no_thp |
Disable Transparent Huge Pages |
API
Allocator
MiMalloc implements GlobalAlloc — all methods use mi_malloc_aligned for guaranteed alignment.
Stats & Options
use MiMalloc;
use mi_option_t;
let version = version; // 30501 = V3.5.1
let json = stats_json; // stats as JSON
let text = stats_print; // stats as text
let info = process_info; // ProcessInfo struct
option_set;
Small Free Fast Paths
MiMalloc::free_csize, free_csize_nonnull, free_small, and
free_small_nonnull expose mimalloc V3.5.1's small and constant-size free fast
paths. These APIs are unsafe: the pointer must come from mimalloc, and the
caller must preserve the original allocation size contract.
Threadpool Hint
set_current_thread_in_threadpool;
Call this from custom thread-pool worker threads to set mimalloc's current-thread threadpool marker.
Heap & Arena
use Heap;
let heap = new.unwrap;
unsafe
heap.delete;
MSRV
Rust 1.96.0. Rolling support window for the latest three stable Rust releases.
License
Apache-2.0.