Skip to content

CEP-0047: Standard Allocator Implementations

Draft

Draft proposal for concrete allocator implementations in std.mem beyond the V1 fixed-buffer allocator.

Summary

Catalyst should eventually define standard allocator implementations and adapters beyond the minimal V1 fixed-buffer allocator.

V1 requires allocation authority to be explicit and defines the prelude/std boundary for allocator APIs. It accepts only std.mem.FixedBufferAllocator as a concrete allocator source for runnable examples and compiler tests; broader allocator declarations remain deferred here.

Example

Possible future shape:

var arena = std.mem.ArenaAllocator.create(std.mem.system_allocator())
defer arena.dispose()

const allocator = arena.allocator()
const item = Box(Item).create(allocator, Item.init())

The proposal must define concrete allocator types, adapters, cleanup, and failure behavior.

Motivation

Useful programs need arenas, reusable fixed-buffer policies, debugging allocators, system allocators, and policy adapters. These must preserve allocation visibility and resource cleanup semantics.

Proposed Direction

The proposal should cover:

  • concrete allocator types beyond std.mem.FixedBufferAllocator;
  • allocation failure behavior;
  • debugging and tracking wrappers;
  • erased allocator adapters;
  • realtime-safe allocator policy;
  • interaction with Box, collections, and dynamic iteration.

Leak-reporting allocators for tests are tracked separately by CEP-0059: Testing Allocator and Leak Reporting.

V1 Compatibility

V1 language semantics do not require or accept a complete allocator implementation catalog. The active V1 standard-library skeleton reserves std.mem for concrete allocators, adapters, tracking wrappers, and policy helpers, and accepts only the monotonic borrowed-buffer std.mem.FixedBufferAllocator. Public allocator implementations, constructors, singletons, erased adapters, reset APIs, reusable free lists, and testing allocators beyond that narrow V1 carveout are deferred until this proposal or a narrower proposal is designed.