subms-arena-allocator 0.5.2

submillisecond.com cookbook recipe - memory: subms-arena-allocator. Fixed-capacity bump-pointer arena with reset() for per-request reuse.
Documentation
  • Coverage
  • 100%
    12 out of 12 items documented1 out of 12 items with examples
  • Size
  • Source code size: 62.47 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 312.71 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kdog007

Arena allocator - Rust

Fixed-capacity bump-pointer arena with reset() for per-request reuse. Allocate is a single cursor bump; reset is constant-time. Auto-grow is opt-in via the growable feature.

Part of the submillisecond.com cookbook. Zero external dependencies; std only.

Install

[dependencies]
subms-arena-allocator = "0.5"

Opt-in features layer focused capability over the fixed-capacity base: typed, growable, stats, aligned, freelist.

Quickstart

cargo test --release
cargo run --example demo

Public API

  • pub struct Bump
  • pub fn new() -> Self
  • pub fn with_capacity(capacity_bytes: usize) -> Self
  • pub fn alloc_copy<T: Copy>(&mut self, value: T) -> &mut T
  • pub fn try_alloc_copy<T: Copy>(&mut self, value: T) -> Option<&mut T>
  • pub fn alloc_raw(&mut self, layout: Layout) -> *mut u8
  • pub fn try_alloc_raw(&mut self, layout: Layout) -> Option<*mut u8>
  • pub fn reset(&mut self)
  • pub fn used(&self) -> usize
  • pub fn capacity(&self) -> usize
  • pub fn total_capacity(&self) -> usize (alias for capacity)

Files

  • src/lib.rs - implementation.
  • tests/ - integration tests; correctness, edge cases, property/stress.
  • examples/demo.rs - stdout walkthrough.
  • examples/perf_main.rs - bench entry (behind the harness feature).

License

Dual-licensed under MIT OR Apache-2.0.