mimalloc is a compact general purpose allocator with excellent performance.
mimalloc is a compact general purpose allocator with excellent performance.
mimalloc (pronounced "me-malloc") is a general purpose allocator with excellent performance characteristics. Initially developed by Daan Leijen for the runtime systems of the Koka and Lean languages.
Latest release : v3.5.1 (2026-09-01) recommended.
Latest v2 release: v2.5.1 (2026-09-01) stable, legacy.
Latest v1 release: v1.15.1 (2026-09-01) legacy.
mimalloc is a drop-in replacement for malloc and can be used in other programs
without code changes, for example, on dynamically linked ELF-based systems (Linux, BSD, etc.) you can use it as:
> LD_PRELOAD=/usr/lib/libmimalloc.so myprogram
It also includes a way to dynamically override the default allocator in Windows. Notable aspects of the design include:
free operations, and another one for concurrent free
operations. Free-ing from another thread can now be a single CAS without needing
sophisticated coordination between threads. Since there will be
thousands of separate free lists, contention is naturally distributed over the heap,
and the chance of contending on a single location will be low -- this is quite
similar to randomized algorithms like skip lists where adding
a random oracle removes the need for a more complex algorithm.The documentation gives a full overview of the API. You can read more on the design of mimalloc in the technical report which also has detailed benchmark results.
Enjoy!
There are three maintained versions of mimalloc. These are mostly equal except for how the OS memory is handled. New development is mostly on v3, while v1 and v2 are maintained with security and bug fixes.
v3.x, development branch dev3).v2.x, development branch dev2 and main)v1.x, development branch dev).
Send PR's against this version if possible.2026-09-01: Added a readme section on getting the best performance.
2026-09-01, v3.5.1, v2.5.1, v1.15.1: (v3) Yet better performance for free calls.
(v3) Added mi_free_small(_nonnull) for runtimes, and mi_free_csize(_nonnull) for inlined constant size free-ing.
(v3) Improved MI_OPT_ARCH options; on arm64, defaults to armv8.3 on Apple and armv8.1 otherwise.
(v3) Default to -DMI_ALLOW_THP=FULL on Linux, where we never split transparent huge pages (THP) during purging (#1282). This
may increase rss but can also improve performance. Use -DMI_ALLOW_THP=OFF to disable the use of THP.
(v3) Improved cache behavior for small allocations. Improved riscV suppor, add riscV to CI. Various small build fixes.
2026-08-18, v1.15.0, v2.5.0, v3.5.0: (v3) slightly better performance for free
using aligned chunks, cleanup cmake options, require armv8.3 (with MI_OPT_ARCH) for
faster load-acquire, increase retired page count from 1 to 3, faster double free
detection in secure mode, use faster atomics for the arena bitmaps (thank you Alan
Andrade, #1346), faster pagemap lookup.
Other: fix numa sparse node count detection (#1365), add theap stats retrieval,
use __builtin_thread_pointer on riscV (#1363), fix C mode compilation on x86 with
msvc (#1361), improved mingw-ucrt64 support.
2026-08-05, v1.9.15, v2.4.5, v3.4.5: Fix compilation with xmalloc (#1353), make the build deterministic (#1355),
mi_zalloc_aligned fix (#763), improve support for mingw (ucrt64), fix fputs fallback on windows (#1354), (v3): use proper
lock backoff for first-class heap deletion, improved riscv64 codegen.
2026-08-01, v1.9.14, v2.4.4, v3.4.4: various bug and security fixes through Opus 5 LLM audit (issue #1271, by @Zoxc).
(v3): use pthreads by default on macOS (issue #1333, issue #1327), fix glibc 2.44 crash (issue #1341), fix alignment check for realloc_aligned. (v1,v2,v3): Add initial mingw support,
set errno on allocation errors, improved double-free checks and size checks in secure mode, enable
build for universal windows platform and xbox (pr #1340), fix numa node detection when numa nodes are sparse.
2026-07-20, v3.4.3: revert TLS slots on macOS to 108/109 (issue #1333).
2026-07-14, v1.9.11, v2.4.1, v3.4.1: various bug and security fixes through LLM audit (by @Zoxc).
Fix issue with using OS memory instead of arenas for > 4GiB memory usage (v3), fix concurrency bug in concurrent
heap destroy (v3), detect riscV virtual address bits at runtime, add riscV TLS support, reduce spinlock waits (v2),
use TLS slots 126/127 on macOS (v3), and other small fixes. All metadata is now separated from heap objects in v3.
2026-04-29, v1.9.10, v2.3.2, v3.3.2: various bug and security fixes through LLM audit (by @Zoxc).
Only increase minimal purge size automatically if allow_thp is set to 2. Enable large OS alignment
on all platforms (fixing OS large pages on Windows). Fix accounting of committed memory on Linux/macOS.
Update MSVC atomics implementation when using C mode. Upstream Emscripten fixes. Proper atomic do-once
implementation.
2026-04-20, v1.9.9, v2.3.1, v3.3.1: various bug and security fixes. Special thanks to
@jinpzhanAMD, @res2k, and @GoldJohnKing for their help in improving Windows finalization, and
@Zoxc for his help in finding various issues.
2026-04-15, v1.9.8, v2.3.0, v3.3.0: initial support for github (binary) releases,
fix visiting of full pages during collection (performance),
fix THP alignment (performance), fix arm64 cross-compilation on Windows, enable guard pages in debug mode,
always use uncommitted areas between arenas (security), enable static overloading of malloc etc. on Windows with the
static CRT (by @Noxybot), fix TLS slot leak on Windows (v3), enable clean DLL load/unload with statically linked
mimalloc (v3), fix race in mi_heap_destroy (v3), by default put page meta info separate from allocated
objects (v3,security), fix C++ overrides for emscripten. Various bugs found by DeepTest include:
fix offset for mi_heap_realloc_aligned, fix mi_(w)dupenv_s buffer size, fix potential overflow in size options,
and error codes for mi_reallocarr(ay).
2026-02-03, v3.2.8 (rc3): Fix thread reinitialize issue on macOS. Fix SIMD codegen bug on older
GCC versions. Extend Windows TLS slot limit from 64 to 1088. Report commit statistics more precise.
Fixes issue in free-page search in arenas.
2026-01-15, v1.9.7, v2.2.7, v3.2.7 (rc2): Fix zero initializing blocks that were OS allocated.
For v3 various bug and performance fixes. Fix Debian 32-bit compilation.
2026-01-08, v1.9.6, v2.2.6, v3.2.6 (rc1): Important bug fixes. Many improvements to v3 including
true first-class heaps where one can allocate in heap from any thread, and track statistics per heap as well.
Added MIMALLOC_ALLOW_THP option. This is by default enabled except on Android. When THP is detected on v3,
mimalloc will set the MIMALLOC_MINIMAL_PURGE_SIZE to 2MiB to avoid breaking up potential THP huge pages.
v3 uses faster TLS access on Windows, and has improved performance for mi_calloc and aligned allocations.
Fixed rare race condition on older v3, fixed potential buffer overflow in debug statistics, add API for returning
allocated sizes on allocation and free.
Special thanks to:
mimalloc.mimalloc is used in v