mimalloc_rust icon indicating copy to clipboard operation
mimalloc_rust copied to clipboard

A Rust wrapper over Microsoft's MiMalloc memory allocator

Mimalloc Rust

Build Status Latest Version Documentation

A drop-in global allocator wrapper around the mimalloc allocator. Mimalloc is a general purpose, performance oriented allocator built by Microsoft.

Usage

use mimalloc::MiMalloc;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

Requirements

A C compiler is required for building mimalloc with cargo.

Usage without secure mode

By default this library builds mimalloc in secure mode. This add guard pages, randomized allocation, encrypted free lists, etc. The performance penalty is usually around 10% according to mimalloc own benchmarks.

To disable secure mode, put in Cargo.toml:

[dependencies]
mimalloc = { version = "*", default-features = false }