Interview Prep/Linux/Processes, memory and OOM

A process is slow and `perf` or `top` shows it constantly page-faulting (`majflt/s` high in `pidstat -r`).

AdvancedTroubleshootingProcesses, memory and OOM
Answer

Likely causes → Memory pages are being read back from disk: swap-ins, or its memory-mapped files are being evicted from page cache because of memory pressure.

Diagnose →

pidstat -r -p <PID> 1 5          # majflt/s
grep -E 'VmSwap' /proc/<PID>/status
cat /proc/pressure/memory /proc/pressure/io

Fix → Give the host or cgroup more memory, reduce other memory consumers, or protect the working set with MemoryLow= / MemoryMin= for that service.

Prevent → Size hosts for the working set plus cache; watch major faults and PSI.

All Linux questions Roadmap: Linux

More on Processes, memory and OOM