Find memory consumed by currently running processes on Linux?

Home / Linux / CentOS / Find memory consumed by currently running processes on Linux?

I always had the question (when I am running plenty of scripts on a linux box as to what is eating up all the memory? Finding memory consumed by current running processes in your favorite linux distro. Luckily, I found a great Python utility (scriplet to be exact).


First download the script

wget http://www.pixelbeat.org/scripts/ps_mem.py

Chmod it to be executed from command line

chmod +x ./ps_mem.py

Then run this script from shell (Putty / SSH)

./ps_mem.py

The output will be similar to the one below (this output is from Ubuntu Server)

root@labs:~# ./ps_mem.py
 Private  +   Shared  =  RAM used       Program

 24.0 KiB +  63.0 KiB =  87.0 KiB       getty [updated] (6)
100.0 KiB +  57.5 KiB = 157.5 KiB       cron
108.0 KiB +  52.0 KiB = 160.0 KiB       getty
132.0 KiB +  66.0 KiB = 198.0 KiB       master
164.0 KiB + 127.5 KiB = 291.5 KiB       upstart-udev-bridge [updated]
180.0 KiB + 192.5 KiB = 372.5 KiB       udevd (3)
276.0 KiB + 136.5 KiB = 412.5 KiB       qmgr
412.0 KiB +  44.5 KiB = 456.5 KiB       rsyslogd
356.0 KiB + 274.5 KiB = 630.5 KiB       pickup
456.0 KiB + 180.5 KiB = 636.5 KiB       init [updated]
676.0 KiB +  98.0 KiB = 774.0 KiB       dbus-daemon [updated]
824.0 KiB + 117.0 KiB = 941.0 KiB       freshclam
  1.1 MiB +  66.5 KiB =   1.2 MiB       bash
  1.1 MiB + 222.5 KiB =   1.4 MiB       console-kit-daemon [updated]
  1.1 MiB + 297.0 KiB =   1.4 MiB       tlsmgr
  1.6 MiB + 986.5 KiB =   2.6 MiB       sshd (2)
  4.3 MiB +  61.5 KiB =   4.3 MiB       mysqld
  8.9 MiB +  93.0 KiB =   9.0 MiB       miniserv.pl
 28.9 MiB +   7.6 MiB =  36.5 MiB       apache2 (11)
---------------------------------
                         61.3 MiB
=================================

 Private  +   Shared  =  RAM used       Program

root@labs:~#

Output/Results on CentOS will be slightly different

root@mystic [~]# ./ps_mem.py
 Private  +   Shared  =  RAM used       Program

 84.0 KiB +  11.5 KiB =  95.5 KiB       klogd
128.0 KiB +  14.5 KiB = 142.5 KiB       syslogd
124.0 KiB +  20.5 KiB = 144.5 KiB       init
288.0 KiB +  20.0 KiB = 308.0 KiB       smartd
292.0 KiB +  20.5 KiB = 312.5 KiB       udevd
308.0 KiB +  61.0 KiB = 369.0 KiB       courierlogger (5)
156.0 KiB + 218.5 KiB = 374.5 KiB       mysqld_safe
344.0 KiB +  90.0 KiB = 434.0 KiB       mingetty (6)
368.0 KiB + 154.0 KiB = 522.0 KiB       authdaemond (6)
512.0 KiB +  47.0 KiB = 559.0 KiB       exim
396.0 KiB + 252.5 KiB = 648.5 KiB       bash
  1.0 MiB +  60.0 KiB =   1.1 MiB       cpanellogd
872.0 KiB + 389.0 KiB =   1.2 MiB       crond (2)
  1.5 MiB + 448.5 KiB =   2.0 MiB       sshd (2)
  2.6 MiB + 202.0 KiB =   2.8 MiB       cphulkd
  3.7 MiB + 159.0 KiB =   3.9 MiB       queueprocd
  3.9 MiB + 333.0 KiB =   4.2 MiB       tailwatchd
  4.1 MiB + 345.0 KiB =   4.4 MiB       leechprotect
  5.2 MiB + 113.5 KiB =   5.3 MiB       named
  6.4 MiB + 967.0 KiB =   7.3 MiB       authProg (5)
  7.7 MiB + 198.0 KiB =   7.9 MiB       miniserv.pl
  2.6 MiB +   5.8 MiB =   8.4 MiB       cpsrvd-ssl (2)
  8.5 MiB + 229.0 KiB =   8.7 MiB       cpdavd
 30.0 MiB +   9.0 MiB =  38.9 MiB       httpd (22)
 19.0 MiB +  33.9 MiB =  52.9 MiB       spamd (3)
 48.6 MiB +   5.1 MiB =  53.7 MiB       php (10)
 84.8 MiB +  32.0 KiB =  84.9 MiB       clamd
---------------------------------
                        291.4 MiB
=================================

 Private  +   Shared  =  RAM used       Program

root@mystic [~]#

2 Comments

Leave a Reply