Created
August 10, 2026 20:22
-
-
Save Reelix/13649a2a6e36bdfae041b196b21c8da1 to your computer and use it in GitHub Desktop.
Find out where your RAM has gone on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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