Skip to main content

detect_memory_pressure

Function detect_memory_pressure 

Source
pub fn detect_memory_pressure() -> Option<f64>
Available on crate feature memory only.
Expand description

Detect THIS container’s own memory pressure as current / limit.

Reads the cgroup’s memory.current (v2) / memory.usage_in_bytes (v1) against its memory.max / memory.limit_in_bytes. Returns None when no cgroup memory limit is in force (bare metal, or memory.max == max), in which case callers should fall back to a process/host signal.

This is the signal a container scheduler (K8s/cgroup OOM killer) actually acts on – unlike host-wide used/total memory, which on a large shared host is unrelated to this container’s limit.