Skip to main content

physical_memory_bytes

Function physical_memory_bytes 

Source
pub fn physical_memory_bytes() -> Option<usize>
Expand description

Returns the physical memory available to this process in bytes: the host’s RAM, clamped by the cgroup memory limit when one is set. Both cgroup v1 and v2 are honored, resolved through /proc/self/mountinfo and /proc/self/cgroup rather than an assumed mount path, so containers (including host-namespace cgroup mounts) do not derive budgets from host RAM. None if detection fails.

Deliberately distinct from any announced memory limit: on nodes whose disk is provisioned as swap, the announced limit includes swap so the memory limiter can bound total heap. Budgets that bound resident bytes must instead derive from memory that can be resident, which is what this reports.