Open and answer this issue on GitHub.
targets, decision, future, safety · opened 2026-11-09 · updated 2026-11-22 · 0 comments
The owner asked (2026-11-09) whether the allocator can be configured, for bare-metal users who must control how memory is managed and for kernel work. This blocks nothing today; it is a question for a later version (future).
[build] names another allocator.std half installs an allocator over a region the build names; allocation = "startup" refuses every allocating call after the executor starts (derived ledger column allocates), and tasks come from a fixed pool (tasks = N).<package>_set_allocator(alloc, free, ctx).task::OverBudget, not the process. List and Text already carry a Place (outside or in the task’s block) as their allocator parameter.skip-free-at-exit swaps in an allocator that skips frees after main.So the places where memory comes from are already parameters inside the runtime, but a program cannot choose one.
| Language | How an allocator is chosen | A failed allocation |
|---|---|---|
| Rust | one #[global_allocator] per program; per-collection allocators (Vec<T, A>) unstable for years |
aborts; try_reserve on some collections |
| Rust for Linux | KVec, KBox take allocation flags (GFP_KERNEL, GFP_ATOMIC) on every allocating call |
returns Err(AllocError) |
| Zig | every allocating function takes an Allocator parameter (FixedBufferAllocator, arena, page) |
returns error.OutOfMemory |
| C++ | std::pmr::memory_resource per container |
throws bad_alloc |
| Odin | an implicit context.allocator, set for a scope |
returns an error value |
| Go, Swift | none; the runtime’s | ends the program |
allocator = "…" in [build], naming a described crate or a package that implements an Allocator trait), like Rust’s #[global_allocator].
For: small, no change to any signature. Against: one choice for the whole program; does not let one part use an arena and another the heap.async(alloc: pool) { … }), as it names limit: today.
For: fits the model already being built; the budget and OverBudget already give a failure path; nothing in ordinary signatures changes. Against: the granularity is a task, not a value.try_ form (or a build setting that makes every allocating call return a Result) so that out of memory is handled where it happens.
For: required for kernels and safety-critical code. Against: a second form of every allocating entry, or a mode that changes types.Option 2 together with 3, and 5 as a build setting for targets that need it (the kernel target, #1494): one allocator per build for the common case, a different one for a task where it matters, and failure as a value where the target demands it. Option 4 is refused for the reasons of ADR-283 D10. Decide once #490 has the block placement (step 5) and OverBudget built, since 3 builds on them.
Found while #490. Related: ADR-119, ADR-283 D7, ADR-284, ADR-327, ADR-348, #1489, #1494.