Skip to content

Instantly share code, notes, and snippets.

@Reelix
Created August 10, 2026 20:22
Show Gist options
  • Select an option

  • Save Reelix/13649a2a6e36bdfae041b196b21c8da1 to your computer and use it in GitHub Desktop.

Select an option

Save Reelix/13649a2a6e36bdfae041b196b21c8da1 to your computer and use it in GitHub Desktop.
Find out where your RAM has gone on Linux
echo "Searching for RAM - Please hold..."
for pid in /proc/[0-9]*; do
if [ -f "$pid/status" ]; then
name=$(grep "^Name:" "$pid/status" 2>/dev/null | awk '{print $2}')
rss=$(grep "^VmRSS:" "$pid/status" 2>/dev/null | awk '{print $2}')
swap=$(grep "^VmSwap:" "$pid/status" 2>/dev/null | awk '{print $2}')
rss=${rss:-0}
swap=${swap:-0}
total=$((rss + swap))
if [ "$total" -gt 102400 ]; then # > 100 MB total
ram_mb=$((rss / 1024))
swap_mb=$((swap / 1024))
total_mb=$((total / 1024))
echo "$total_mb MB Total ($ram_mb MB RAM + $swap_mb MB Swap) -> $name (PID: ${pid##*/})"
fi
fi
done | sort -nr | head -n 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment