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:
debug: Enable the
Debug mode in
1mib: Use the
1mib chunk configuration. From
0.2.17, this is set as a default feature
16mib: Use the
16mib chunk configuration.
cache-friendly: Make the allocator more cache friendly (setting
64 in building the
snmalloc for the native CPU of the host machine. (this is not a default behavior
madvise problem of QEMU environment
stats: Enable statistics
local_dynamic_tls: Workaround cannot allocate memory in static tls block
build_cc: Use of cc crate instead of cmake (cmake still default) as builder (more platform agnostic)
usecxx20: Enable C++20 standard if available
usecxx17: Use C++17 standard
check: 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)
To get the crates compiled, you need to choose either
16mib to determine the chunk configuration
snmalloc-rs add it as a dependency:
snmalloc-rs = "0.3.4"
SnMalloc as the global allocator add this to your project:
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
Notice: since version
0.2.12, we no longer require you to provide additional environment variables for
ANDROID_NDK must be provided as an environment variable
ANDROID_PLATFORM can be passed as an optional environment variable
ANDROID_ABI used by CMake is detected automatically
android-lld can be used to set the linker of
android-shared-std can be used to set the STL library of
c++_shared (it uses
libstdc++ is no longer a dependency)
build_cc feature (broken in 0.3.0 release).
native-cpu feature (broken in 0.3.0 release).