← Memory & Performance
Linux · Memory & Performance
How to find which processes are using swap in Linux
Find which processes are consuming swap by reading VmSwap from /proc/*/status, ranked highest first.
When swap fills up, find which processes hold the most. Each process reports its swapped memory as VmSwap in /proc/PID/status.
# Swap used per process (VmSwap), biggest first - run as root
for f in /proc/*/status; do
awk '/^Pid:/{pid=$2} /^Name:/{name=$2} /^VmSwap:/{print $2" kB",pid,name}' "$f"
done 2>/dev/null | sort -rn | head -n 15
# If smem is installed (simpler):
# smem -s swap -r | headLinuxswapMemory