
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.6.1 (2026-10-30) recommended.\
Latest v2 release: v2.5.2 (2026-09-12) stable, legacy.\
Latest v1 release: v1.15.2 (2026-09-12) 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 (and otherwise dev3).v3.6.1: (v3) Many small fixes for CPython integration (thank you @DinoV),
Emscripten fixes (#1455, thank you @kleisauke) and reduced memory usage on WASI and Emscripten,
C23 free_sized(_aligned) overrides (#1470), improved fork support (#1456),
fix armv5tej compilation (#1464), fix MSVC overrides for strdup family (#1460),
faster STL allocator trait (#1468),
always use a 2-level pagemap for security and simplicity.
Experimental support for CHERI platforms. Improved Rust bindings (thank you @OscarTHZhang and @Techcable).
Add -DMI_SECURE=MINIMAL as improved security with minimal (~1%) performance impact which
puts guard pages around all mimalloc meta-data (but does not encode free lists).
Move all static variables into a mi_process_t struct (that is guarded).v3.6.0: (v3) add initial profiling hooks and default profiler, "always on"
detailed statistics per size-bin, and always-on profiling. Initial rust bindings. Better support
for large OS page sizes, support a quiescent state based reclamation interfacec (for CPython),
better cache line aware allocation, fix heap visitor where some pages might be skipped, improve
fork support, avoid over-allocation for naturally aligned allocations, fix stderr console output
for XBox, fix huge allocation rollback, refactor the source and include files, immediately purge
very large allocations, fix bcrypt dependency on windows, fix heap-destroy bug when a fresh heap
was allocated at the same address (giving a segfault), page_reclaim_on_free is now on by default.v3.5.3: (v3) critical bug fix (where the first new on a thread could
fail on some platforms #1398). Fix bug with mi_free_size on overaligned small allocations (#1400).v3.5.2, v2.5.2, v1.15.2: (v3) Reduced cache contention, improved mi_malloc_csize,
improved zero'ing of small blocks, mi_wmalloc variants for runtime systems, always enable detailed
statistics. Experimental support for profiling hooks (mimalloc-profile.h).v3.5.1, v2.5.1, v1.15.1: (v3) Yet better performance for free calls.
(v3) Added mi_free_small(_nonnull) for fast small allocations, 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 support. Various small build fixes.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.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.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.v3.4.3: revert TLS slots on macOS to 108/109 (issue #1333).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 con| 日期 | 榜单 | 排名 | 周期新增 | 总 STAR |
|---|