Expand description
Memory: how much there is, how much is in use, and how much this process may use, container-aware by default.
Inside a container or a systemd unit with a memory limit, total is the
limit: what this process can use and what the out-of-memory killer
enforces. The host’s values are one call away (host_total).
use sys_lib as sys;
println!("{} of {} used ({})", sys::mem::used()?, sys::mem::total()?, sys::mem::used_percent()?);Structs§
- Activity
- Swap and paging activity over an interval: whether the machine is thrashing.
- Huge
Pages - Explicit huge pages and the transparent-huge-page mode.
- Memory
- Every memory value from one set of reads; see
snapshot. - Memory
Events - Out-of-memory events, counted since the cgroup (or the machine) started.
- Memory
Limit - A memory limit on this process.
- Memory
Module - An installed memory module. Never the serial number.
- Sampler
- Measures swap and paging activity between samples. Owned by the caller: two
samplers never disturb each other.
samplenever blocks and allocates nothing. - Swap
- Swap space. All zero when there is none; never NaN in any percentage.
Enums§
- Event
Scope - What
MemoryEventscount. - Limit
Source - Where a container or job limit came from.
- Memory
Form - A module’s physical form.
- Memory
Kind - A memory technology.
- Memory
Source - Where
Memory::totalandMemory::usedcame from. - Transparent
Huge Pages - The Linux transparent-huge-page mode.
Functions§
- activity
- Swap and paging activity over the next second. Blocks for one second;
a monitor keeps a
Samplerinstead. - events
- Whether this container (or machine) has been running out of memory. A watchdog compares two readings and sheds load before the next kill.
- free
- Memory available to new allocations without swapping: reclaimable cache
counts as available (
MemAvailableon Linux). - free_
percent freeas a share oftotal.- host_
free - Memory available on the machine, ignoring any limit.
- host_
total - The machine’s memory, ignoring any limit.
- huge_
pages - Explicit huge pages and the transparent-huge-page mode, which databases and
JIT runtimes care about. Linux:
/proc/meminfoand/sys/kernel/mm/transparent_hugepage/enabled. Windows: the large page minimum (the pool counts are zero). macOS:None. - limit
- The memory limit on this process, or
Nonewhen there is none (or it is at or above the machine’s memory). Linux: the smallest cgroup v2memory.maxover the cgroup and its ancestors, or cgroup v1’shierarchical_memory_limit. Windows: the job object’s process or job memory limit. macOS has no equivalent:None. - modules
- The installed memory sticks, from the SMBIOS type 17 records; empty slots are left out.
- page_
size - The size of a memory page in bytes (a static fact).
- pressure
- How much work is stalled waiting for memory (
Pressure). Linux: the cgroup’smemory.pressure, else/proc/pressure/memory;Noneon kernels without pressure-stall information. macOS: the kernel’s memory-pressure level, with no stall shares. Windows:Criticalwhen the system signals low memory, elseNormal, with no stall shares. - snapshot
- Every memory value from one set of reads, swap included. A caller who wants several values calls this once.
- swap
- Swap space. All zero when there is none (E-31). zram counts as swap; zswap is invisible to these counters (E-32).
- total
- What this process may use: the host’s memory, or the container’s (or job object’s) limit when that is smaller. A live reading: the limit can change while a process runs (Kubernetes in-place resize, VM ballooning).
- used
- Memory in use, counted against
total. Inside a limit it is the container’s working set: current usage minus inactive file pages, the definition the kubelet uses for eviction. - used_
percent usedas a share oftotal.