bumpalo

A fast bump-allocation arena for Rust with mass deallocation and optional collections

Library
Cargo
v3.20.3
2,302stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
62/100Good
Development Activity60
Maintenance28
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture90
Code Quality90
Innovation82
Learning Curve75

bumpalo is a fast bump-allocation arena for Rust. It holds a chunk of memory and a pointer into it; allocating an object is little more than a bounds check and a pointer bump, which makes allocation extremely cheap. When a program phase ends, the entire arena is freed at once by resetting the pointer, rather than deallocating objects one at a time.

This phase-oriented model suits workloads like compilers, parsers, and request handlers that allocate many short-lived values and drop them together. bumpalo offers a Bump arena, an optional Box wrapper that runs Drop, and arena-backed Vec and String collections, with no_std support and an experimental allocator_api integration.

What You Get

  • A Bump arena with alloc, alloc_with, and try_alloc methods for placing values into arena memory
  • Mass deallocation by resetting the arena, with automatic new-chunk growth when full
  • An optional bumpalo::boxed::Box<T> that runs Drop while living in the arena
  • Arena-backed collections (Vec and String) behind the collections feature, plus no_std and allocator_api support

Common Use Cases

  • Allocating short-lived AST or IR nodes in a compiler or parser
  • Per-request or per-frame arenas that are reset wholesale after each cycle
  • High-throughput code paths where individual allocation cost matters

Under The Hood

Architecture - The core lives in a large src/lib.rs (~2,900 lines) defining the Bump arena, which maintains a linked list of memory chunks and a current-chunk footer holding the bump pointer. Allocation checks remaining capacity, bumps the pointer (with alignment handling), and requests a new, typically larger chunk from the global allocator on overflow. boxed.rs and emplace.rs add Drop-aware wrappers, and the collections/ module provides arena-backed Vec, String, and raw_vec implementations that mirror std’s APIs against arena memory.

Tech Stack - Pure Rust (edition 2021) with zero required runtime dependencies. Optional features gate collections, boxed, the experimental allocator_api, and serde support; the crate builds on no_std targets.

Code Quality - Widely used (hundreds of millions of downloads), with careful unsafe code around raw allocation, dedicated tests including OOM/fallible paths (tests/try_alloc.rs) and regression tests, plus benches. The code is mature and heavily reviewed.

API Design - The everyday surface is small and ergonomic: construct a Bump, call alloc/alloc_with to get &mut T references, and reset to reclaim everything. Fallible try_alloc variants and the collections mirror familiar std shapes, so basic use is trivial while the arena’s lifetime and no-individual-Drop semantics require some understanding, keeping the learning curve moderate.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search