How do I find which process is slowly eating my RAM?

Quick Linux Tip #12:

Try: watch -n 5 'ps -eo pid,user,vsz,rss,comm --sort=-rss | head -20'

Info: watch runs the command repeatedly, showing memory trends. RSS shows physical memory in KB. If a process's RSS keeps growing, you have a leak.

Examples:

  • $ watch -n 1 'free -m'
  • $ smem -tk -s rss  # More accurate memory reporting
  • $ sudo pmap -x 1234 | tail -1  # Detailed memory map

Note: smem is more accurate than ps for shared memory. Install with apt install smem. Monitor over hours to detect slow leaks.




LinuxTeck.com
linuxteck@ubuntu:~$ watch -n 5 'ps -eo pid,user,vsz,rss,comm --sort=-rss | head -20'

Every 5.0s: ps -eo pid,user,vsz,rss,comm --sort=-rss
    PID USER      VSZ      RSS COMMAND
   3456 mysql   4823456 2345678 mysqld
   2134 www     2145678  987654 apache2
   5678 user    1876543  765432 chrome
   4321 root     987654  543210 systemd-journal
   1234 nginx    567890  234567 nginx

PREVIOUS ARTICLE Quick Linux Tip #11: How do I debug a running process without stopping it? NEXT ARTICLE Quick Linux Tip #13: I deleted a log file but the app is still writing to it. Can I recover it?
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.