pub fn pressure() -> Result<Option<Pressure>>Expand description
How much work is stalled waiting for memory (Pressure). Linux: the
cgroup’s memory.pressure, else /proc/pressure/memory; None on kernels
without pressure-stall information. macOS: the kernel’s memory-pressure
level, with no stall shares. Windows: Critical when the system signals low
memory, else Normal, with no stall shares.
use sys_lib::{self as sys, PressureLevel};
if let Some(p) = sys::mem::pressure()? {
if p.level >= PressureLevel::Warning { /* trim caches */ }
}§Errors
Malformed when the kernel’s file does not parse.