#memory-pool #heap-allocation #arena #dealocations

yanked arena-rs

An arena memory pool for fast heap allocations and dealocations

0.1.1 Dec 5, 2019
0.1.0 Dec 5, 2019

#57 in #memory-pool

MIT license

4KB
56 lines

Arena-rs

Crates.io

An arena memory pool for fast Rust heap allocations and dealocations.

This allows data to be allocated instantly and destroyed in batches.

Creating an Arena

let mut arena = Arena::new(1024 /* size in bytes*/);

Allocating data

let value = arena.alloc(17)?;
assert_eq!(*value, 17);

Deallocating data

{
    let arena = Arena::new(1024);
} // <- All data in arena is deallocated here

Saftey

let arena = Arena::new(1024);
let value = arena.alloc(17)?;
move_arena(arena);
println!("{}", *value); // <- Compiler Error
// The arena was destroyed when we gave it to `move_arena`
// so we cannot use any data it gave to us

No runtime deps