Part 2 · 1 chapters · ~8 min

Memory

Working set size, MemAvailable versus MemFree, page faults and their rate, reclaim (kswapd and direct reclaim), swapping and swappiness, PSI memory, NUMA locality, huge pages, process memory (RSS, PSS, USS), leak growth over time, and OOM analysis.

3

Pressure, reclaim, faults

code
free -m                              # 'available' column: what new work can actually use
vmstat 1                             # si/so > 0 sustained → swapping hurts
sar -B 1                             # pgscank/s (kswapd) vs pgscand/s (direct reclaim: stalls)
cat /proc/pressure/memory            # full avg10 > 0 → all non-idle tasks stalled on memory at times
smem -tk -s pss                      # per-process PSS: fair share of shared pages
numastat -p $(pgrep -o java)         # remote NUMA node access: slower memory
perf stat -e page-faults,major-faults -p $(pgrep -o node) -- sleep 10

Leaks vs caches: a process whose RSS grows forever and never plateaus under steady load is leaking; one that grows then plateaus is filling a cache (Backend Diagnosis P2 has the lab). NUMA: on multi-socket servers, memory on another socket is slower; pin large databases to a node or interleave.

MEMORY: FROM PRESSURE TO OOM
what happens as memory runs out
plentypage cache growspressurekswapd reclaims cachedirect reclaimallocations stallswappinganonymous pages to diskOOM killera process dies
swipe the figure sideways, or tap expand for full screen
1/4
cache fills memory
A healthy Linux box has little free memory: the page cache uses the rest and gives it back when needed. Watch MemAvailable, not MemFree.
free memory becomes cacheMemAvailable is the real number