8 releases

✓ Uses Rust 2018 edition

new 0.2.4 Feb 13, 2020
0.2.3 Feb 6, 2020
0.2.1 Jan 24, 2020
0.1.2 Jan 21, 2020

#63 in Memory management

Download history 53/week @ 2020-01-17 33/week @ 2020-01-24 35/week @ 2020-01-31 73/week @ 2020-02-07

62 downloads per month

MIT license

1.5K SLoC

C++ 1.5K SLoC // 0.0% comments Rust 113 SLoC // 0.4% comments


travis ci

snmalloc-rs provides a wrapper for microsoft/snmalloc to make it usable as a global allocator for rust. snmalloc is a research allocator. Its key design features are:

  • Memory that is freed by the same thread that allocated it does not require any synchronising operations.
  • Freeing memory in a different thread to initially allocated it, does not take any locks and instead uses a novel message passing scheme to return the memory to the original allocator, where it is recycled.
  • The allocator uses large ranges of pages to reduce the amount of meta-data required.

Some old benchmark results are available in the snmalloc paper. There are three features defined in this crate:

  • debug: Enable the Debug mode in snmalloc.
  • 1mib: Use the 1mib chunk configuration.
  • cache-friendly: Make the allocator more cache friendly (setting CACHE_FRIENDLY_OFFSET to 64 in building the library).

To use snmalloc-rs add it as a dependency:

# Cargo.toml
snmalloc-rs = "0.2"

To set SnMalloc as the global allocator add this to your project:

static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;