Expand description
Runtime memory accounting.
The accounting is intentionally explicit:
- a buffer is charged for the bytes it stores (
len), the same unit a registerStr/Bytespays on this budget; - spare capacity the caller allocated before handing the buffer over is not charged;
- replacements release the old charge;
Dropreleases the final charge;- failed reservations never modify the current value.
Order for overwrite (S3):
reserve(new) → release(old) → install(new)Never install before releasing the previous charge. Peak usage during a
successful replace is therefore old + new until the old charge is
released — a same-size swap can fail against a tight ceiling even though
the steady-state footprint would fit.
§What this does not guarantee
HeapStr / HeapBytes charge the bytes they store. Rust code that
builds a String / Vec before handing it over has already allocated;
spare capacity in that buffer is invisible to the budget, the same way a
register Str pays str.len().
RuntimeConfig::max_runtime_bytes is therefore a
runtime-managed accounting ceiling, not a global allocator sandbox.
Structs§
- Heap
Bytes - Opaque byte buffer charged against a
MemoryBudget. - HeapStr
- UTF-8 heap buffer charged against a
MemoryBudget. - Memory
Budget - Process- or scope-wide byte budget with atomic charge/release.
- Memory
Snapshot - Point-in-time view of a budget (read-only observability).
Enums§
- Memory
Error - Fail-closed memory reservation error.