#memory-allocator #unsafe #multi-threading #malloc #resources

nightly rusty_malloc

A multithreaded yet simple memory allocator written in Rust

3 unstable releases

0.2.1 Sep 5, 2024
0.2.0 Sep 5, 2024
0.1.0 Sep 3, 2024

#257 in Memory management

Download history 67/week @ 2024-08-28 307/week @ 2024-09-04 46/week @ 2024-09-11 33/week @ 2024-09-18 30/week @ 2024-09-25 31/week @ 2024-10-02

67 downloads per month

Custom license

75KB
1.5K SLoC

Rusty Malloc

Crates.io Documentation MIT licensed

A multithreaded yet simple memory allocator written in Rust.

This crate is a hobby project I did to get hands-on experience with unsafe Rust. Nevertheless, I made an effort to write good documentation so that it can also serve as a learning resource.

Usage

To use this crate you can add rusty_malloc as a dependency in your project's Cargo.toml.

[dependencies]
rusty_malloc = "0.2"
use rusty_malloc::RustyMalloc;
use rusty_malloc::growers::BrkGrower;

#[global_allocator]
static ALLOCATOR: RustyMalloc<BrkGrower> = unsafe { RustyMalloc::with_grower(BrkGrower::new(4096)) };

fn main() {
    let v1: Vec<u32> = vec![1, 2, 3];
    println!("Brk is cool {:?}", v1);
}

To read more about the allocator's mode of operation, check out the documentation.

Dependencies

~345–495KB