Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ps-mem - Another Memory Monitoring Tool

I have a new favourite memory monitoring tool. It provides a nice breakdown of the memory used by each running process, along with a total as shown below:

 Private  +   Shared  =  RAM used   Program

  4.0 KiB +  11.0 KiB =  15.0 KiB   cat
 64.0 KiB +  10.5 KiB =  74.5 KiB   uml_switch
100.0 KiB +  25.5 KiB = 125.5 KiB   atd
172.0 KiB +  34.5 KiB = 206.5 KiB   upstart-event-bridge
192.0 KiB +  20.5 KiB = 212.5 KiB   acpid
188.0 KiB +  29.0 KiB = 217.0 KiB   rpc.idmapd
204.0 KiB +  20.0 KiB = 224.0 KiB   mdadm
208.0 KiB +  23.5 KiB = 231.5 KiB   irqbalance
208.0 KiB +  41.5 KiB = 249.5 KiB   rpc.statd
224.0 KiB +  46.0 KiB = 270.0 KiB   kerneloops
248.0 KiB +  33.5 KiB = 281.5 KiB   bluetoothd
248.0 KiB +  38.0 KiB = 286.0 KiB   rtkit-daemon
268.0 KiB +  41.0 KiB = 309.0 KiB   cron
272.0 KiB +  40.5 KiB = 312.5 KiB   rpcbind
332.0 KiB +  27.0 KiB = 359.0 KiB   upstart-socket-bridge
324.0 KiB +  35.5 KiB = 359.5 KiB   dnsmasq
340.0 KiB +  65.5 KiB = 405.5 KiB   unity-webapps-service
292.0 KiB + 135.5 KiB = 427.5 KiB   master
280.0 KiB + 151.0 KiB = 431.0 KiB   qmgr
504.0 KiB +  60.5 KiB = 564.5 KiB   systemd-logind
536.0 KiB +  66.0 KiB = 602.0 KiB   upstart-dbus-bridge (2)
488.0 KiB + 119.0 KiB = 607.0 KiB   cups-browsed
464.0 KiB + 149.0 KiB = 613.0 KiB   pickup
508.0 KiB + 138.0 KiB = 646.0 KiB   getty (6)
528.0 KiB + 138.0 KiB = 666.0 KiB   dbus
616.0 KiB +  75.0 KiB = 691.0 KiB   gvfs-mtp-volume-monitor [updated]
660.0 KiB +  33.0 KiB = 693.0 KiB   upstart-udev-bridge
652.0 KiB +  43.0 KiB = 695.0 KiB   rpc.mountd
636.0 KiB +  78.0 KiB = 714.0 KiB   at-spi-bus-launcher
656.0 KiB +  70.5 KiB = 726.5 KiB   gvfsd-burn [updated]
664.0 KiB +  76.5 KiB = 740.5 KiB   gvfsd [updated]
548.0 KiB + 196.5 KiB = 744.5 KiB   whoopsie
660.0 KiB +  90.5 KiB = 750.5 KiB   ibus-dconf
720.0 KiB +  72.5 KiB = 792.5 KiB   gvfsd-metadata [updated]
588.0 KiB + 210.5 KiB = 798.5 KiB   avahi-daemon (2)
716.0 KiB +  86.0 KiB = 802.0 KiB   at-spi2-registryd
748.0 KiB +  88.5 KiB = 836.5 KiB   indicator-power-service
788.0 KiB +  56.0 KiB = 844.0 KiB   dconf-service
856.0 KiB +  85.5 KiB = 941.5 KiB   gvfs-gphoto2-volume-monitor [updated]
824.0 KiB + 134.0 KiB = 958.0 KiB   ModemManager
488.0 KiB + 472.5 KiB = 960.5 KiB   window-stack-bridge
984.0 KiB +  87.0 KiB =   1.0 MiB   upstart-file-bridge (2)
992.0 KiB +  89.0 KiB =   1.1 MiB   ibus-engine-simple
  1.0 MiB +  55.5 KiB =   1.1 MiB   systemd-udevd
884.0 KiB + 239.0 KiB =   1.1 MiB   ccnet
960.0 KiB + 191.5 KiB =   1.1 MiB   mission-control-5
  1.0 MiB + 136.5 KiB =   1.1 MiB   gvfsd-http
  1.2 MiB + 131.5 KiB =   1.3 MiB   upowerd
  1.1 MiB + 276.0 KiB =   1.3 MiB   geoclue-master
  1.0 MiB + 580.5 KiB =   1.6 MiB   sudo (2)
  1.5 MiB +  85.0 KiB =   1.6 MiB   tmux
  1.6 MiB +  88.5 KiB =   1.7 MiB   gconfd-2
  1.4 MiB + 321.5 KiB =   1.7 MiB   ubuntu-geoip-provider
  1.8 MiB + 180.0 KiB =   1.9 MiB   NetworkManager
  1.7 MiB + 216.5 KiB =   2.0 MiB   console-kit-daemon
  1.8 MiB + 221.0 KiB =   2.0 MiB   ibus-x11
  1.9 MiB + 270.0 KiB =   2.1 MiB   indicator-sound-service
  1.8 MiB + 386.0 KiB =   2.2 MiB   cupsd
  2.3 MiB + 115.0 KiB =   2.5 MiB   accounts-daemon
  2.4 MiB + 179.5 KiB =   2.5 MiB   zeitgeist-daemon [updated]
  2.0 MiB + 620.5 KiB =   2.6 MiB   virsh
  2.3 MiB + 274.5 KiB =   2.6 MiB   polkit-gnome-authentication-agent-1
  2.6 MiB +  70.0 KiB =   2.7 MiB   indicator-bluetooth-service
  2.6 MiB + 123.5 KiB =   2.7 MiB   gvfsd-trash [updated]
  2.7 MiB +  84.0 KiB =   2.8 MiB   gvfsd-fuse [updated]
  2.5 MiB + 355.5 KiB =   2.9 MiB   evolution-source-registry
  2.9 MiB +  92.0 KiB =   3.0 MiB   indicator-messages-service
  2.9 MiB + 134.0 KiB =   3.0 MiB   deja-dup-monitor
  3.1 MiB + 162.0 KiB =   3.3 MiB   indicator-application-service
  3.1 MiB + 281.0 KiB =   3.4 MiB   lightdm [updated] (2)
  3.1 MiB + 386.0 KiB =   3.5 MiB   telepathy-indicator
  3.0 MiB + 490.0 KiB =   3.5 MiB   pulseaudio
  3.5 MiB + 109.5 KiB =   3.6 MiB   polkitd
  3.6 MiB + 101.0 KiB =   3.7 MiB   gnome-keyring-daemon
  3.4 MiB + 370.0 KiB =   3.7 MiB   gnome-session
  3.6 MiB + 174.5 KiB =   3.8 MiB   colord
  3.5 MiB + 397.0 KiB =   3.8 MiB   indicator-printers-service
  3.7 MiB + 302.0 KiB =   4.0 MiB   init (2)
  3.8 MiB + 466.5 KiB =   4.3 MiB   dbus-daemon (3)
  4.2 MiB + 208.5 KiB =   4.4 MiB   gvfs-udisks2-volume-monitor [updated]
  1.2 MiB +   3.2 MiB =   4.5 MiB   sshd (5)
  4.6 MiB +  83.5 KiB =   4.7 MiB   gvfs-afc-volume-monitor [updated]
  4.5 MiB + 289.5 KiB =   4.8 MiB   zeitgeist-datahub [updated]
  4.4 MiB + 410.0 KiB =   4.8 MiB   unity-scope-home
  4.5 MiB + 341.5 KiB =   4.9 MiB   unity-fallback-mount-helper [updated]
  5.3 MiB + 104.5 KiB =   5.4 MiB   indicator-session-service
  5.3 MiB + 316.0 KiB =   5.6 MiB   indicator-datetime-service
  5.4 MiB + 451.5 KiB =   5.8 MiB   ibus-ui-gtk3
  5.5 MiB + 490.5 KiB =   6.0 MiB   nm-applet
  5.1 MiB + 920.5 KiB =   6.0 MiB   notify-osd
  5.6 MiB + 499.5 KiB =   6.0 MiB   libvirtd
  5.9 MiB + 439.5 KiB =   6.3 MiB   update-notifier
  6.3 MiB + 113.0 KiB =   6.4 MiB   ibus-daemon
  6.2 MiB + 204.5 KiB =   6.4 MiB   udisksd
  6.7 MiB +  51.0 KiB =   6.7 MiB   rsyslogd
  6.7 MiB + 464.0 KiB =   7.2 MiB   bamfdaemon
  7.1 MiB + 343.0 KiB =   7.4 MiB   indicator-keyboard-service
  7.1 MiB + 656.5 KiB =   7.8 MiB   unity-settings-daemon [updated]
  7.4 MiB + 450.0 KiB =   7.9 MiB   unity-files-daemon
  7.8 MiB + 828.0 KiB =   8.6 MiB   psensor
 10.3 MiB + 683.0 KiB =  10.9 MiB   unity-scope-loader
 11.7 MiB + 530.5 KiB =  12.2 MiB   zeitgeist-fts [updated]
  6.0 MiB +   7.2 MiB =  13.2 MiB   apache2 (6)
 12.4 MiB + 963.0 KiB =  13.3 MiB   bash (4)
 19.7 MiB +   1.4 MiB =  21.1 MiB   synapse
 24.4 MiB + 936.5 KiB =  25.3 MiB   hud-service
 25.6 MiB +   1.9 MiB =  27.4 MiB   seafile-applet
 28.7 MiB +   1.0 MiB =  29.7 MiB   unity-panel-service
 31.3 MiB + 379.5 KiB =  31.7 MiB   evolution-calendar-factory
 34.2 MiB + 485.0 KiB =  34.7 MiB   seaf-daemon
 30.1 MiB +   7.9 MiB =  38.0 MiB   python2.7 (4)
 65.9 MiB +   9.2 MiB =  75.1 MiB   nautilus
 78.1 MiB +  17.1 MiB =  95.2 MiB   Xorg
201.3 MiB +   8.4 MiB = 209.8 MiB   plugin-container
250.1 MiB +  10.2 MiB = 260.3 MiB   compiz
302.7 MiB +   8.6 MiB = 311.3 MiB   firefox
  6.4 GiB + 482.6 MiB =   6.9 GiB   qemu-system-x86_64 (17)
---------------------------------
                          8.3 GiB
=================================

This is in stark contrast to htop, which proved a whole lot less useful as demonstrated from the same server below:

Note: Observant readers may have noticed that htop is showing far more memory being utilized than the 8.3 GiB that ps-mem showed. For some reason, the ZFS ARC does not register in htop, top, or ps-mem it seems.

Installation

wget https://raw.githubusercontent.com/pixelb/ps_mem/master/ps_mem.py
sudo mv ps_mem.py /usr/sbin/ps-mem
sudo chmod +x /usr/sbin/ps-mem

Usage

General

sudo ps-mem

Non-grouped

If you don't want similar processes to be grouped (such as my qemu-system in the example above), then run:

sudo ps-mem --split-args

More usage information can be found on the developer's Github page.

References

Last updated: 16th August 2018
First published: 16th August 2018