Rust 1.100 stabilises custom allocators after 10 years in limbo

A post on cetra3.github.io, dated 24 November 2026, welcomes the stabilisation of custom allocators in Rust after what its author calls 10 years of limbo. The author feels the never type stole some of the thunder, but calls Rust 1.100 a monumental release all the same and congratulates the team that got it through. What is available now is described as an MVP of the allocator API. Beyond closer feature parity with languages such as C++ and Zig, the post sets out three uses for it.

The first is controlling when memory is freed. Dropping values in Rust is not free, the author notes. Handing large nested structures to a dedicated thread to drop them is only half a fix, because the deallocation calls are still paid for, just outside the hot path. Many workloads, such as a web request or a database query, allocate heavily, use the data and then discard all of it at once. A bump allocator suits that pattern: it reserves one large block and advances a counter for each allocation instead of calling the system allocator every time. It does not track individual allocations for release, so everything is freed together. The example takes a single 32 MiB block from the global allocator, builds a chain of a million linked nodes inside it and then drops the allocator, which a code comment says takes virtually no time. The sample returns an error when the block is full, where a real bump allocator would grab another.

Not every allocation benefits, so the author stresses the value of changing allocation strategy locally and not only globally. Bumping through large amounts of memory could also raise memory use considerably.

That leads to the second use, memory accounting. A thin wrapper around an existing allocator adds the size of each successful allocation to an atomic counter and subtracts it on deallocation. In the example, a cache built on the wrapper reports 1,024 bytes, then 5,120, then 0 once dropped. Such figures could drive cache eviction above a threshold, an external sort that uses as much memory as possible, or a limit on a code sandbox that shares resources with others.

A single atomic counter carries some performance overhead. The author plugs thresher, a crate of their own that combines a local (per task or thread) counter with a global one to avoid contention, reporting back every 64KiB of allocation, and fires a callback at a set threshold. In the demo the threshold is 100 MiB, and the printed callback reports 167772160 bytes. Only allocations made through the thresher handle are counted. The author says thresher is used in production on logfire to produce heap profiles of Rust services when memory hits a configured threshold.

The third use, which the author calls probably the most esoteric, is controlling where memory lives. Like smallvec, a toy allocator keeps the first 8KiB on the stack and sends anything that does not fit to the heap. The author notes that smallvec is more battle tested.

Key facts

  • Custom allocators are now stable in Rust after 10 years in limbo; the post ties the milestone to Rust 1.100 and calls the API an MVP.
  • A bump allocator example takes one 32 MiB block, builds a million linked nodes in it and releases everything at once.
  • Wrapping an existing allocator with a byte counter gives memory accounting for caches, external sorts and sandbox limits.
  • The author's thresher crate fires a callback at a memory threshold and, per the author, provides heap profiles of Rust services in production on logfire.
  • A toy allocator serves requests from an 8KiB stack buffer and falls back to the heap when they do not fit.

Why it matters

The author puts the wait at 10 years and sees the stable API as bringing Rust closer to feature parity with system languages such as C++ and Zig. In practical terms, code can now pick an allocation strategy for a particular structure or section and not only for the whole program. Bulk freeing was one of the leading cases for custom allocation, because tearing down many individual values costs time.

Who it affects

The post is aimed at the everyday Rust programmer. The cases it describes include services whose requests or database queries allocate in bursts, caches that need to evict entries above a size limit, external sorts that do not know their data sizes in advance, and code sandboxes that share resources with other sandboxes. Developers who need to control where memory lives get the third, more niche example.

How to use it

The examples implement the Allocator trait, with its allocate and deallocate methods, on a reference to a custom type, then pass that reference to constructors such as Vec::new_in or Box::new_in. A bump allocator makes deallocate a deliberate no-op and returns its whole block when it is dropped. An accounting layer forwards both calls to an inner allocator, such as Global, and updates a counter. For threshold callbacks there is the thresher crate: set a threshold, set a callback and allocate through its handle. The author says the crate also includes a jemalloc example for instrumenting heap profiles.

How solid is it

This is a developer's blog post explaining the feature with code samples, not official release documentation. No benchmarks or timing measurements are given for the bump allocator, the accounting allocator, thresher or the stack allocator, so the speed argument rests on how the designs work. The thresher section is a self-declared plug: the author created the crate and reports using it in production.

Risks and caveats

The examples are illustrations: the author calls the accounting one very trivial and the stack one a toy. The bump allocator does not release individual allocations, may considerably increase memory use when large amounts pass through it, and in sample form fails once its 32 MiB block is full. A single atomic counter adds some overhead. With thresher, buffers taken from the global allocator do not count towards the threshold. The sample implementations also rely on unsafe Rust.

“This is actually only half a solution. You're still paying for the deallocation call costs, just it's not in the hot path anymore.”

— The post's author, on moving drops to a dedicated thread