docs / Getting Started / Memory Diagnostics

Memory Diagnostics

Miri manages memory for you, which means a reference-counting mistake is a compiler bug rather than yours. These tools exist to catch such bugs — they are how the standard library above was brought to a provably leak-free state, and running your own program under them costs you nothing but a rebuild.

ToolHowWhat it reports
Shadow heapMIRI_HEAP_GUARD=1An ASan-style shadow heap that traps use-after-free and double-free at the moment they happen, and attributes each leak to the allocation site. Silent on a correct program.
Allocation countMIRI_ALLOC_COUNT=1Exact allocation totals for the run, split by category, so a change in allocation behaviour is measurable rather than guessed at.
RC verifier--verify-mirA path-sensitive check of the reference-counting invariants after the Perceus transform. Reports any imbalance as a hard error.

The verifier also honours the MIRI_VERIFY_MIR environment variable, which is how it runs across the compiler's own test suite on every change.