Ferroc: A Multithread Lock-free Memory Allocator
Ferroc (combined from "ferrum" and "malloc") is a lock-free concurrent memory allocator written in Rust, primarily inspired by mimalloc.
This memory allocator is designed to work as fast as other mainstream memory allocators while providing flexible configurations such as embedded/bare-metal environment integrations.
Examples
If you simply want to utilize another memory allocator, you can use Ferroc as the global allocator with default features:
use Ferroc;
static FERROC: Ferroc = Ferroc;
If you want more control over the allocator, you can disable the default features and enable the ones you need:
= { = "*", = false, = ["base-mmap"]}
use ;
Cargo Features
- Basic features: generic
Arenas,Contexts andHeaps; "stat": Statistics counters support;"base-static": Base allocatorStatic;"base-mmap": Base allocatorMmapbased on os-specific virtual memory managers (stdandlibcrequired);"global": Global allocator instantiation macrosconfig!andconfig_mod!(inner thread local statics are leaked by default);"libc":libcdependency (currently required bypthreadoption inconfig*!if you want apthreadthread-local destructor);"default": The default global allocatorFerrocprovided byMmapandpthreadthread-local destructor (consisting of all the features above);"c":fe_*C functions for C/C++ targets and a generated C/C++ header"ferroc.h"in the root directory, and replacement for default allocator functions such asmallocif--cfg sys_allocis specified;"track-valgrind": Valgrind memory tracking support based oncrabgrind;"finer-grained": Add more object size types to small bins, decreasing fragmentation but also the minimal alignment from 16 to 8, potentially leading some programs that need SIMD to fail for misalignment.
Benchmarks
Using a subset of mimalloc-bench for benchmarking. Running on my laptop with 16GB of RAM and an Intel i7-10750H CPU @ 2.60GHz. The process is repeated 10 times and the results are averaged and taken as logarithms.
Time consumed:

Memory consumed:

Caveats
This crate only supports the latest nightly Rust compiler currently and utilizes many unstable features. Use it with care.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.