#allocator #rustix #port #ported #linux #dlmalloc

rustix-dlmalloc

A Rust port of the dlmalloc allocator, ported to rustix

7 releases

0.1.7 Oct 6, 2024
0.1.6 Jun 12, 2024
0.1.5 Mar 1, 2024
0.1.4 Jan 30, 2024
0.1.0 Aug 25, 2023

#61 in Memory management

Download history 20/week @ 2024-07-29 6/week @ 2024-08-05 40/week @ 2024-08-12 178/week @ 2024-08-19 99/week @ 2024-08-26 13/week @ 2024-09-02 15/week @ 2024-09-09 36/week @ 2024-09-16 101/week @ 2024-09-23 325/week @ 2024-09-30 736/week @ 2024-10-07 249/week @ 2024-10-14 85/week @ 2024-10-21 66/week @ 2024-10-28 48/week @ 2024-11-04 61/week @ 2024-11-11

348 downloads per month
Used in 6 crates (3 directly)

MIT/Apache

310KB
6K SLoC

C 3.5K SLoC // 0.4% comments Rust 2K SLoC // 0.0% comments

rustix-dlmalloc

This is a port of the dlmalloc-rs crate to rustix.

The "global" feature currently depends on rustix-futex-sync, which is only supported on Linux.

Original README.md follows

A port of dlmalloc to Rust.

Documentation

Why dlmalloc?

This crate is a port of dlmalloc to Rust, and doesn't rely on C. The primary purpose of this crate is to serve as the default allocator for Rust on the wasm32-unknown-unknown target. At the time this was written the wasm target didn't support C code, so it was required to have a Rust-only solution.

This allocator is not the most performant by a longshot. It is primarily, I think, intended for being easy to port and easy to learn. I didn't dive too deep into the implementation when writing it, it's just a straight port of the C version.

It's unlikely that Rust code needs to worry/interact with this allocator in general. Most of the time you'll be manually switching to a different allocator :)

License

This project is licensed under either of

at your option.

Contribution

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

Dependencies

~0–10MB
~110K SLoC