Parent: #459 Depends on: #461, #476, #477, #479
Goal
Treat memory footprint, fragmentation, executable-code lifetime, and cache retention as first-class performance gates alongside throughput.
Scope
- Add retained/peak RSS and owned-byte accounting by GC generation/slab/cell kind, strings/backing, arrays/buffers, shapes/ICs, parser/AST/bytecode, JIT artifacts/metadata/maps, modules, inspector, and caches.
- Define bounded policies for code cache, retired epochs, compilation metadata, atoms/strings, regex plans, formatter caches, realm templates, allocator slabs, and thread-local reserves.
- Trigger safe GC/compaction/code eviction under memory pressure without thrash, invalid entry, latency cliffs, or repeated compilation storms.
- Improve object/cell/layout density only with ABI and exact allocation-class evidence; preserve stable IDs and relocation.
- Add fragmentation and long-lived mixed-graph benchmarks, not just explicit compaction's retained tail.
No-workaround rules
- No throughput win purchased with unbounded retention, process-global leak, disabled reclamation, or opaque allocator cache.
- Do not delete reproducible build caches as a runtime memory “fix”;
.zig-cache/zig-outare out of process scope.
Acceptance
- Machine-readable memory inventory reconciles owned allocations/bytes at checkpoints and teardown.
- Long-running workloads reach a bounded plateau; forced pressure safely reclaims GC and code/cache memory.
- Compaction retains its 90.8% fragmented-backing reduction and exact checksum/fixed-point contract.
- Latency/throughput/RSS evidence is published together for every memory-policy change.
- Leak, fault/OOM, moving GC, no-GIL, TSan, ABI, and code-retirement gates pass.
Foundation
#144/#433; explicit compaction report; GC object finalizer optimization 14d94ec0.