Skip to content

Allocator Model โ€‹

Interface โ€‹

Everything is expressed through std.mem.Allocator (verified against lib/std/mem/Allocator.zig in the 0.16.0 SDK): alloc / resize / remap / free plus the convenience wrappers (alloc, dupe, alignedAlloc, free).

Containers โ€‹

  • Unmanaged std.ArrayList(T) (.empty, methods taking gpa) backs every growable buffer: stacks, pools, scratch, matches.
  • Managed std.StringHashMap / AutoHashMap are available for maps; the hot paths avoid hashing entirely.
  • std.heap.ArenaAllocator wraps batch workloads; the library's memory.Arena adds reset/queryCapacity conveniences.

Rules enforced by tests โ€‹

  • One handoff (Parser.init); inheritance everywhere else.
  • No std.heap.page_allocator fallback, no global singleton, no per-operation allocator parameters on the hot path.
  • OutOfMemory propagates with partial state cleaned up (failing-allocator tests).
  • std.testing.allocator across the suite means any leak fails CI.

Allocators, Ownership, Allocator API

Released under the MIT License.