pub struct Stats {
pub mapped: u64,
pub live: u64,
pub rounding: u64,
pub cache: u64,
pub span_free: u64,
pub returned: u64,
pub virgin: u64,
pub hysteresis: u64,
pub segment_overhead: u64,
pub large_count: u64,
pub spans_assigned: u64,
}Expand description
A snapshot of where every mapped byte is.
Fields§
§mapped: u64Total bytes mapped from the OS. The anchor.
live: u64Sum of Layout::size() over live allocations — what callers
actually asked for, unrounded.
rounding: u64Sum of (slot size − requested size) over live allocations.
cache: u64Bytes parked on foreign-free lists, waiting to be drained home.
span_free: u64Free slots in spans that were handed out before and returned to the free pool: touched, therefore resident.
returned: u64Free slots whose pages have been handed back to the OS while their span stays live — mapped, not resident. The v2 term: this is what page-granular reclaim produces, and it did not exist while the reclaim unit was the whole span.
virgin: u64Span bytes at or above the bump cursor — mapped, never touched, not resident.
hysteresis: u64Whole spans with nothing live, retained rather than released.
segment_overhead: u64Segment headers.
large_count: u64Live allocations served by direct mapping rather than a class.
spans_assigned: u64Spans currently assigned to a size class. Exported because “did we keep claiming fresh spans past reusable ones” is not visible in any byte count — the identity balances either way.
Implementations§
Source§impl Stats
impl Stats
Sourcepub fn accounted(&self) -> u64
pub fn accounted(&self) -> u64
The sum the identity asserts. Kept separate from Self::mapped
so a test can compare the two rather than trusting one.
§Examples
use kevy_alloc::Stats;
// The identity this exists to check: every mapped byte is in
// exactly one bucket, so the sum is comparable to `mapped`
// rather than derived from it.
let s = Stats::default();
assert_eq!(s.accounted(), 0);
assert_eq!(s.mapped, 0);Sourcepub fn predicted_resident(&self) -> u64
pub fn predicted_resident(&self) -> u64
Bytes we expect to be resident: everything mapped except what was never touched or has been handed back to the OS.
An estimate by construction — the kernel decides residency, not us — so it is named as a prediction and compared against real RSS by the gate rather than substituted for it.