https://github.com/embarkstudios/rpmalloc-rs
🐏 rpmalloc global memory allocator for Rust 🦀
https://github.com/embarkstudios/rpmalloc-rs
memory-allocation rpmalloc rust rust-crate
Last synced: 6 months ago
JSON representation
🐏 rpmalloc global memory allocator for Rust 🦀
- Host: GitHub
- URL: https://github.com/embarkstudios/rpmalloc-rs
- Owner: EmbarkStudios
- License: apache-2.0
- Created: 2019-01-05T15:14:41.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2025-03-12T14:51:19.000Z (10 months ago)
- Last Synced: 2025-06-20T01:50:38.083Z (7 months ago)
- Topics: memory-allocation, rpmalloc, rust, rust-crate
- Language: Rust
- Homepage: http://embark.rs
- Size: 64.5 KB
- Stars: 148
- Watchers: 7
- Forks: 15
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# `🐏 rpmalloc-rs`
**Cross-platform Rust global memory allocator using [rpmalloc](https://github.com/rampantpixels/rpmalloc).**
[](https://embark.dev)
[](https://discord.gg/dAuKfZS)
[](https://crates.io/crates/rpmalloc)
[](https://docs.rs/rpmalloc)
[](https://deps.rs/repo/github/EmbarkStudios/rpmalloc-rs)
[](https://github.com/EmbarkStudios/rpmalloc-rs/actions?workflow=CI)
## Overview
See the [rpmalloc README](https://github.com/mjansson/rpmalloc/blob/master/README.md) 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:
```toml
[dependencies]
rpmalloc = "0.2.0"
```
And then in one of your `.rs` files:
```rust
#[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:
```toml
[dependencies]
rpmalloc = { version = "0.2.0", features = ["guards", "statistics"] }
```
See [rpmalloc README](https://github.com/mjansson/rpmalloc/blob/master/README.md) 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
[](../CODE_OF_CONDUCT.md)
We welcome community contributions to this project.
Please read our [Contributor Guide](CONTRIBUTING.md) for more information on how to get started.
## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.
Note that the [rpmalloc](https://github.com/rampantpixels/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.