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. Includes things the heap counter cannot see: mapped libraries, allocator overhead, and any memory allocated inside vendored C++ rather than through Rust's global allocator.
The gap between them is the cost of everything that is not our data structures. For blad that is dominated by libjxl's own working set, which the heap counter cannot see at all — exactly the kind of thing that stays invisible if you only measure one.
Both numbers are for this process only. /usr/bin/time -l includes children and
will attribute a subprocess's peak to us; that mistake was made once here already.
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.