0.1.1 |
|
---|---|
0.1.0 |
|
#48 in #memory-pool
4KB
56 lines
Arena-rs
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