Skip to main content

Module bump

Module bump 

Source
Expand description

Lock-free bump (linear) allocator.

A bump allocator maintains a single monotonically-increasing offset into a fixed backing buffer. Each allocation simply advances the offset by the required (aligned) size.

§Trade-offs

ProCon
O(1) allocation with zero fragmentationNo individual deallocation
Thread-safe without a mutex (CAS loop)Must call [reset] to reclaim memory
Minimal memory overhead per allocationBuffer size fixed at construction

§Usage

static mut BUF: [u8; 4096] = [0u8; 4096];
let bump = BumpAllocator::new(unsafe { &mut BUF });
let vec: ExVec<u32> = ExVec::new(&bump);

Structs§

BumpAllocator
A thread-safe, lock-free bump allocator backed by a static byte buffer.