Rust Allocator API Is Stable in 1.100: How to Use It (bumpalo Isn't Ready Yet)
Rust 1.100 shipped on November 12 with the Allocator trait on stable, which means custom allocators for Vec and Box without nightly. You can now give one Vec its own arena, keep everything else on the global heap, and do it without #![feature(allocator_api)] or a forked collection type. The tracking issue, rust-lang/rust#32838, dates from 2016. cetra3, who has been writing about this for most of the year, sums it up as "after 10 years of limbo" in The State of Allocators in 2026 - Finally Stabilised!.
The stable surface is small, though. bumpalo, the arena crate most people reach for, doesn't plug into it yet, and most of the speedup numbers people will throw at you in the comments are years old. Below I go through what landed and what I'd leave alone, with a 46-line arena that runs on stable today.
What the Rust allocator API stabilisation includes
From the Rust 1.100.0 release post, the stabilised items are:
-
std::alloc::Allocator,std::alloc::Global,std::alloc::System, andimpl AllocatorforGlobalandSystem - blanket impls for
&A,&mut A,Box<T, A>,Arc<T, A>andRc<T, A> - on
Box:new_in,from_raw_in,from_non_null_in,into_raw_with_allocator,into_non_null_with_allocator,allocator - on
Vec:new_in,with_capacity_in,from_raw_parts_in,from_parts_in,into_raw_parts_with_allocator,into_parts_with_allocator,allocator
The release team calls it "the core parts of allocator_api" and the start of the Allocators 1.0 project goal. Only Vec and Box take an allocator. HashMap, BTreeMap, VecDeque and String don't, so no stable String<A> yet.
The trait has two required methods, quoted in cetra3's September status post:
unsafe trait Allocator { fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>; unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout); } The same post lists what was left out on purpose. Box::pin_in is out of the MVP because a 'static bound alone wasn't a strong enough guarantee to rule out unsound use (#157089), and the blanket Clone for Arc<T, A> was unsound too (#156920). Marker traits like AllocatorClone and StaticAllocator are being discussed. The aim is for the trait to be dyn-compatible from the start, and cetra3 expects Vec::new_in(Arc<dyn Allocator>) to become the usual pattern in libraries. Allocators may not unwind, and allocation failure still aborts rather than panics.
I think shipping the MVP was right. Two soundness holes turned up in the months before stabilisation. Holding the whole thing back to fix Pin and Clone would have meant another year of nightly for everyone who only wanted Vec::new_in.
Before and after: moving a hot Vec to an arena
The usual case is per-request scratch space. You build a Vec of tokens, rows or nodes, use it, and throw it away, thousands of times a second. Before:
fn handle(req: &Request) -> Response { let mut tokens: Vec<Token> = Vec::with_capacity(64); tokenize(req, &mut tokens); build_response(&tokens) } // every push that grew the Vec hit malloc, and the drop hits free After, with a deliberately tiny bump arena written against the stable trait only. It has one fixed 1 MiB chunk that never grows, and deallocate does nothing:
use std::alloc::{AllocError, Allocator, Global, Layout}; use std::cell::Cell; use std::ptr::NonNull; const CHUNK: usize = 1 << 20; // 1 MiB pub struct Arena { base: NonNull<u8>, used: Cell<usize>, } impl Arena { fn layout() -> Layout { Layout::from_size_align(CHUNK, 16).unwrap() } pub fn new() -> Self { let base = Global.allocate(Self::layout()).expect("arena").cast::<u8>(); Arena { base, used: Cell::new(0) } } // &mut self: the borrow checker won't let you reset while a Vec still borrows the arena pub fn reset(&mut self) { self.used.set(0); } } impl Drop for Arena { fn drop(&mut self) { unsafe { Global.deallocate(self.base, Self::layout()) } } } unsafe impl Allocator for &Arena { fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> { let base = self.base.as_ptr() as usize; let offset = (base + self.used.get()).next_multiple_of(layout.align()) - base; let end = offset.checked_add(layout.size()).ok_or(AllocError)?; if end > CHUNK { return Err(AllocError); // a real arena grabs another chunk here } self.used.set(end); let ptr = unsafe { self.base.add(offset) }; Ok(NonNull::slice_from_raw_parts(ptr, layout.size())) } unsafe fn deallocate(&self, _ptr: NonNull<u8>, _layout: Layout) {} } fn handle(req: &Request, arena: &Arena) -> Response { let mut tokens: Vec<Token, &Arena> = Vec::with_capacity_in(64, arena); tokenize(req, &mut tokens); build_response(&tokens) } fn serve(reqs: impl Iterator<Item = Request>) { let mut arena = Arena::new(); for req in reqs { let resp = handle(&req, &arena); send(resp); arena.reset(); // "free" everything from this request at once } } The changes at the call site are Vec<Token> becoming Vec<Token, &Arena>, with_capacity becoming with_capacity_in, and a reset() per iteration. Element destructors still run when the Vec drops; the arena just skips releasing the memory.
A few caveats, since this is where arenas bite:
- Growth copies. A
Vecthat outgrows its capacity allocates a new block and copies, and the old block stays in the arena untilreset. Size it withwith_capacity_inor you'll fill 1 MiB with dead buffers. -
tokenizenow needs to accept&mut Vec<Token, A>. cetra3's example isfn do_something<A: Allocator>(my_vec: &mut Vec<u32, A>) {}. Every helper that takes&mut Vec<T>by concrete type has to change, and that's where most of the migration work goes. - Hand this code to a real crate as soon as one supports the std trait. The toy above has no chunk growth and has had none of the testing bumpalo has.
Do bumpalo, allocator-api2, mimalloc and jemalloc still matter?
Yes, but for different reasons than a month ago.
| Crate | What it's for | Status after 1.100 |
|---|---|---|
| bumpalo | Bump arena | README still marks the allocator_api feature as nightly-only and outside semver. Latest release is 3.20.4 (2026-11-13), the day after 1.100, but it's a security fix for zero-sized allocations across threads and says nothing about the std trait. On stable you use its allocator-api2 feature or bumpalo::collections::Vec |
| allocator-api2 | Stable mirror of the nightly API | Latest changelog entry is 0.4.0 (11.12.2025). The README says that when allocator_api is stable the crate "will get version 1.0 and simply re-export from core, alloc and std". That hasn't shipped yet |
| mimalloc | Global allocator | Unaffected. Still #[global_allocator] static GLOBAL: MiMalloc = MiMalloc; |
| tikv-jemallocator | Global allocator | Unaffected, same pattern. cetra3's thresher repo has a jemalloc example |
So the most popular arena crate does not yet implement std::alloc::Allocator on stable, going by its own docs. The release is barely three weeks old, so it's no scandal, but "arenas on stable" means "your own arena on stable" until bumpalo and allocator-api2 cut releases. cetra3 also points out that MSRV policies will slow crate adoption across the ecosystem.
Where are the benchmarks?
I went looking for published benchmarks of "per-Vec arena vs global allocator" tied to this release. Neither cetra3 post has any. The November post says dropping a bump arena after building a chain of a million parent-linked nodes "takes virtually no time at all", which I believe, but it isn't a measurement.
What does get cited is mimalloc's own suite. Its README performance section says "Last update: 2021-01-30" and was run against jemalloc 5.2.1 and glibc 2.31. That's vendor data on a setup from January 2021. The README's verifiable claims are that mimalloc "outperforms other leading allocators (jemalloc, tcmalloc, Hoard, etc), and often uses less memory", and that secure mode costs "usually around 10% on average" (the newer secure-mode section splits that into levels, from usually under 5% for BASIC to "usually less than 25%, but can be 2 to 3x slower" for ON, with FULL above that). If someone posts "arenas are 10x faster", ask which workload.
My take: swapping the global allocator is still the cheapest experiment you can run. It's one line, and you can measure it against your own p99 in an afternoon. A per-collection arena is for when a profile shows malloc/free in one specific hot path. The new API makes that path much less painful, but I still wouldn't start there.
Will crates accept your Vec<T, &Arena>?
The one sharp question in the lobste.rs thread came from nickmonad, who wrote they had "somewhat left Rust" for Zig, "primarily because of these patterns": "Will there be libraries that use this and some that don't?" marcprux replied that crates may put allocator support behind a feature flag. I expect exactly that, and I expect it to be messy for a couple of years. Zig made allocators explicit from day one. Rust is bolting them on with a default type parameter, so a crate whose public API takes Vec<T> won't accept your Vec<T, &Arena> until it's rewritten.
What to do this week
- Bump to Rust 1.100 and grep for
#![feature(allocator_api)]. If you only usedVec,Boxand the methods listed above, delete the feature gate. - If you depend on allocator-api2 only to get
Vec<T, A>on stable, watch for its 1.0 rather than ripping it out now. - In a library, add
A: Allocator = Globalto the types where callers will want it. cetra3 makes the same request: let library consumers bring their own allocator. - Don't write your own arena for production unless you're ready to own the
unsafe.
Which allocator are you running in production Rust right now: system, mimalloc, jemalloc, or a hand-rolled arena? And did you ever measure the difference, or did you copy the #[global_allocator] line from a blog post?