Skip to main content

Module mem

Module mem 

Source
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.
HugePages
Explicit huge pages and the transparent-huge-page mode.
Memory
Every memory value from one set of reads; see snapshot.
MemoryEvents
Out-of-memory events, counted since the cgroup (or the machine) started.
MemoryLimit
A memory limit on this process.
MemoryModule
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. sample never blocks and allocates nothing.
Swap
Swap space. All zero when there is none; never NaN in any percentage.

Enums§

EventScope
What MemoryEvents count.
LimitSource
Where a container or job limit came from.
MemoryForm
A module’s physical form.
MemoryKind
A memory technology.
MemorySource
Where Memory::total and Memory::used came from.
TransparentHugePages
The Linux transparent-huge-page mode.

Functions§

activity
Swap and paging activity over the next second. Blocks for one second; a monitor keeps a Sampler instead.
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 (MemAvailable on Linux).
free_percent
free as a share of total.
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/meminfo and /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 None when there is none (or it is at or above the machine’s memory). Linux: the smallest cgroup v2 memory.max over the cgroup and its ancestors, or cgroup v1’s hierarchical_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’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.
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
used as a share of total.