Skip to main content

Module memory

Module memory 

Source
Expand description

Runtime memory accounting.

The accounting is intentionally explicit:

  • allocations are charged when capacity is acquired;
  • replacements release the old allocation;
  • Drop releases the final allocation;
  • 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 buffers they own. Rust code that builds a String / Vec before handing it to HeapStr::new has already allocated; the budget only learns about that capacity after the fact. RuntimeConfig::max_runtime_bytes is therefore a runtime-managed accounting ceiling, not a global allocator sandbox.

Structs§

HeapBytes
Opaque byte buffer charged against a MemoryBudget.
HeapStr
UTF-8 heap buffer charged against a MemoryBudget.
MemoryBudget
Process- or scope-wide byte budget with atomic charge/release.
MemoryLimit
Hard ceiling for a MemoryBudget.
MemorySnapshot
Point-in-time view of a budget (read-only observability).

Enums§

MemoryError
Fail-closed memory reservation error.