#allocator #rpmalloc

rpmalloc

Cross-platform global memory allocator using rpmalloc

4 releases

✓ Uses Rust 2018 edition

0.1.3 Nov 5, 2019
0.1.2 Nov 1, 2019
0.1.1 Nov 1, 2019
0.1.0 Nov 1, 2019

#35 in Memory management

MIT/Apache

315KB
6.5K SLoC

C 3K SLoC // 0.1% comments Python 2.5K SLoC // 0.1% comments Visual Studio Project 451 SLoC Rust 172 SLoC // 0.6% comments C++ 136 SLoC Visual Studio Solution 40 SLoC

🐏 rpmalloc-rs

Build Status Crates.io Docs Contributor Covenant Embark

Cross-platform Rust global memory allocator using rpmalloc.

See the rpmalloc README for a detailed description of how the allocator works, peforms, and compares with other allocators.

How to use

To use rpmalloc as the global allocator in your Rust binary crate, in Cargo.toml add:

[dependencies]
rpmalloc = "0.1.0"

And then in one of your .rs files:

#[global_allocator]
static ALLOC: rpmalloc::RpMalloc = rpmalloc::RpMalloc;

Configuration

It is also possible to configure how the allocator should be built through a set of feature flags that correspond to the rpmalloc C library ENABLE_x defines:

  • Overall: statistics, validate_args, asserts, guards
  • Cache: unlimited_cache, unlimited_global_cache, unlimited_thread_cache, global_cache, thread_cache, adaptive_thread_cache

Example usage:

[dependencies]
rpmalloc = { version = "0.1.0", features = ["guards", "statistics"] }

See rpmalloc README for detailed descriptions of the config options.

Note that all of these have not been tested together with this Rust crate.

Support

This crate has been tested to support the following platforms and Rust targets:

  • x86_64-pc-windows-msvc
  • x86_64-apple-darwin
  • x86_64-unknown-linux-gnu

PRs to increase the amount of supported targets are welcome, but they should add CI verification and avoid adding additional dependencies.

Contributing

We welcome community contributions to this project.

Please read our Contributor Guide for more information on how to get started.

License

Licensed under either of

at your option.

Note that the rpmalloc library this crate uses is under public domain, and can also be licensed under MIT.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies