Expand description
Resident Set Size (RSS) sampling for memory diagnostics.
Used by the allocator benchmark (vtcode bench-allocator) to measure whether
the global allocator returns memory to the OS after bursty/sparse workloads.
Unlike performance_profiler::get_memory_usage_mb (Linux /proc only, fake
fallback on macOS), this returns a real value on every supported platform.
Functionsยง
- resident_
set_ size_ mb - Returns the current process Resident Set Size in megabytes, or
Noneif it cannot be determined on the current platform. - sample_
peak_ rss_ mb - Sample RSS repeatedly, returning the maximum observed value in MB. Useful for capturing peak memory during a burst of activity.
- sample_
peak_ rss_ mb_ while - Like
sample_peak_rss_mb, but stops early onceshould_continuereturnsfalse. The predicate is checked before each sample, so a caller measuring a burst can release the sampler as soon as the burst ends instead of waiting out a worst-case timeout. Intended for blocking threads (e.g.spawn_blocking): each poll is a syscall followed bythread::sleep, which must not run on a Tokio worker. - sample_
rss_ mb - Sample RSS once and return the value in MB (0.0 if unavailable).