Memory instrumentation.
Two numbers, deliberately, because they answer different questions and their difference is itself informative:
- Heap — bytes we allocated, counted exactly by wrapping the global allocator. Resettable, so it can be attributed per phase.
- RSS — what the OS considers resident, a monotonic high-water mark from
getrusage. Includes things the heap counter cannot see: dirty pages from temp files, mapped libraries, allocator overhead.
The gap between them is the cost of everything that is not our data structures. For blad that is dominated by the temp files the shell-out codec round-trips through — which is exactly the kind of thing that stays invisible if you only measure one.
Usage
The binary installs the allocator:
#[global_allocator]
static ALLOC: blad_mem::Tracking<std::alloc::System> =
blad_mem::Tracking(std::alloc::System);
Without that, [heap_peak] reports zero and everything still works — instrumentation
must never be load-bearing.