← Back to AILP Home

Handles

A handle is an opaque 64-bit token (Handle<T>) that names an allocation inside a generational arena. Handles give you:

When to reach for a handle vs gc / wild

You want… Use
Lots of short-lived allocations, all freed together Handle
One thing collected when nothing references it gc
Explicit alloc / defer free with a known shape wild
Executable memory with W^X lifecycle wildx

Handles sit between gc (zero ceremony, arbitrary lifetime) and wild (full manual control). They are the right answer when you have a bulk of allocations whose lifetime matches a known scope (a request, a parse, a frame) and you would otherwise be writing your own free list.

Chapters

  1. README — this page.
  2. ArenasHandleArena.create / destroy, capacity, when to use one big arena vs many small ones.
  3. HandlesHandle<T>, allocation, deref, free, the generation counter, runtime UAF behaviour.
  4. Lifetimes — the borrow-checker rule that catches handle-outlives-arena at compile time (ARIA-032).
  5. FFI — handing a handle's underlying pointer across the C boundary without losing the safety net, plus the #[destroys_arena(<param>)] attribute for externs.
  6. Cross-module — how ARIA-032 flows across use boundaries: imported function summaries, transitive destroy/escape, cross-module $$i return-borrow.
  7. Diagnostics — every handle-related error / warning, smallest reproducer, canonical fix.
  8. FAQ — recurring questions about handles.

See also

Validation