Memory, cache and pressure
Quick answer
Available memory estimates how much memory can be used without swapping. Low free memory alone is normal when Linux uses RAM for cache. Pressure, active reclaim and swap traffic help distinguish useful cache from harmful contention.
A machine can have little free RAM yet enough available memory for new work. Repeated reclaim stalls, swap activity and allocation failures provide different evidence from a single memory snapshot. Use a time series and check workload limits before concluding memory is exhausted.
Prepare the practice environment
Run python3 lab-fixtures/performance/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Run each snippet in a separate Bash process, not your interactive shell. Only private files are used; optional examples require an authorized snapshot VM. Do not change live monitoring or services. All supplied records are fictional; live read-only header checks do not retain measurements. Review the lab guide.
Prerequisites
Review: CPU utilization and load average.
How it works
Page cache holds file data and can often be reclaimed; not all cached memory is immediately reclaimable. MemAvailable is an estimate, not simply free plus cache. Compare swap-in and swap-out rates (vmstat si and so) over a relevant interval, rather than total swap occupancy. Pressure Stall Information (PSI) describes time lost waiting for a resource: memory some means at least one task is stalled, full means all non-idle tasks are stalled at once. avg10/60/300 are percentages over smoothed time windows; total is cumulative stall microseconds. A difference between two total values divided by elapsed microseconds yields an interval fraction when the counter is continuous. In containers inspect the relevant cgroup as well as system scope. A memory limit can cause OOM even when host RAM is available.
Try the examples
awk -F, 'NR>1 {print $1, "available_MiB=" $3, "swap_out_KiB_s=" $4}' memory.csvBoth have little free RAM; the second has much less available RAM and active swap-out.
Expected stdout:
cache available_MiB=4096 swap_out_KiB_s=0pressure available_MiB=128 swap_out_KiB_s=2048The fictional some and full values overlap; do not add them.
Expected stdout:
some avg10=12.50full avg10=3.00250000 microseconds of stall in one second gives 25%. A reset is rejected by the helper.
Expected stdout:
25.00% stalledCommon mistakes
Do not clear page cache or disable swap as a first response. Collect evidence and examine application memory, limits and pressure before proposing changes.
Practice
Compare the two memory samples, calculate a 100000 microsecond stall delta over two seconds, and explain which metrics would support a memory-pressure hypothesis.
Related references
Study: free, vmstat. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Memory, cache and pressure — Knowledge Check
Apply performance-analysis concepts to synthetic fixtures and VM-only scenarios.
Which metric estimates memory available without swapping?
What is memory PSI full?
What is a 100000 us stall over 2 seconds?
What suggests active memory contention?