| Crates.io | snmalloc-rs |
| lib.rs | snmalloc-rs |
| version | 0.3.8 |
| created_at | 2020-01-20 15:24:41.124937+00 |
| updated_at | 2025-02-06 03:22:24.831479+00 |
| description | rust bindings of snmalloc. |
| homepage | https://github.com/microsoft/snmalloc |
| repository | https://github.com/SchrodingerZhu/snmalloc-rs |
| max_upload_size | |
| id | 200473 |
| size | 25,924 |
Notice: MinGW Build is broken and may not be fixed in a near future. See this PR in the upstream.
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:
Some old benchmark results are available in
the snmalloc paper. Some recent benchmark results
are listed at
bench_suite. There are three features defined in this crate:
debug: Enable the Debug mode in snmalloc.1mib: Use the 1mib chunk configuration. From 0.2.17, this is set as a default feature16mib: Use the 16mib chunk configuration.cache-friendly: Make the allocator more cache friendly (setting CACHE_FRIENDLY_OFFSET to 64 in building the
library).native-cpu: Optimize snmalloc for the native CPU of the host machine. (this is not a default behavior
since 0.2.14)qemu: Workaround madvise problem of QEMU environmentstats: Enable statisticslocal_dynamic_tls: Workaround cannot allocate memory in static tls blockbuild_cc: Use of cc crate instead of cmake (cmake still default) as builder (more platform agnostic)usecxx20: Enable C++20 standard if availableusecxx17: Use C++17 standardcheck: Enable extra checks to improve security, see upstream security docs.
Note that the memcpy protection is not enabled in Rust.win8compat: Improve compatibility for old Windows platforms (removing usages of VirtualAlloc2 and other new APIs)lto: Links with InterProceduralOptimization/LinkTimeOptimizationnotls: Enables to be loaded dynamically, thus disable tls.stats: Enables allocation statistics.To get the crates compiled, you need to choose either 1mib or 16mib to determine the chunk configuration
To use snmalloc-rs add it as a dependency:
# Cargo.toml
[dependencies]
snmalloc-rs = "0.3.8"
To set SnMalloc as the global allocator add this to your project:
#[global_allocator]
static ALLOC: snmalloc_rs::SnMalloc = snmalloc_rs::SnMalloc;
mingw version is only tested on nightly branch with MSYS environment. We are using dynamic linking method. Hence,
please make sure the following libs are in your PATH:
winpthreadatomicstdc++gcc_sNotice: since version 0.2.12, we no longer require you to provide additional environment variables for mingw
target.
ANDROID_NDK must be provided as an environment variableANDROID_PLATFORM can be passed as an optional environment variableANDROID_ABI used by CMake is detected automaticallyandroid-lld can be used to set the linker of snmalloc to lldandroid-shared-std can be used to set the STL library of snmalloc to c++_shared (it uses c++_static by
default)libstdc++ is no longer a dependency)build_cc feature (broken in 0.3.0 release).native-cpu feature (broken in 0.3.0 release).