Command Line Tool of the Day: ps_mem – show how much RAM is used per program

1. What is ps_mem?

ps_mem is a tool that can be used to show how much memory is used per program. It does this by calculating the sum of private RAM for program processes and the sum of shared RAM for program processes.

2. How to install ps_mem

In order to install ps_mem, you will need to be running CentOS 6.5 (this package became available with CentOS 6.5). ps_mem is installed with a single package:

 yum install ps_mem

3. How to use ps_mem

ps_mem with sample output:


# ps_mem
Private  +   Shared  =  RAM used Program
4.0 KiB +  32.5 KiB =  36.5 KiB mysqld_safe
4.0 KiB +  36.0 KiB =  40.0 KiB screen
4.0 KiB +  42.0 KiB =  46.0 KiB xinetd
0.0 KiB +  53.5 KiB =  53.5 KiB udevd (2)
80.0 KiB +  31.5 KiB = 111.5 KiB rpcbind
24.0 KiB + 105.0 KiB = 129.0 KiB mingetty (6)
152.0 KiB + 101.0 KiB = 253.0 KiB master
212.0 KiB +  50.5 KiB = 262.5 KiB auditd
180.0 KiB + 120.0 KiB = 300.0 KiB qmgr
256.0 KiB +  54.0 KiB = 310.0 KiB init
356.0 KiB +  27.0 KiB = 383.0 KiB dhclient
264.0 KiB + 359.5 KiB = 623.5 KiB smbd (2)
352.0 KiB + 291.5 KiB = 643.5 KiB sshd (2)
652.0 KiB +  91.5 KiB = 743.5 KiB crond
1.1 MiB +  64.5 KiB =   1.2 MiB rsyslogd
1.4 MiB + 624.0 KiB =   2.0 MiB pickup
2.6 MiB + 111.0 KiB =   2.7 MiB zsh (2)
3.3 MiB + 103.0 KiB =   3.4 MiB mysqld
6.8 MiB +   8.6 MiB =  15.4 MiB httpd (9)
---------------------------------
28.6 MiB
=================================

To show the command line of each program:

# ps_mem -s

To refresh program memory usage every X seconds:

# ps_mem -w X
Share This Post

About Author: Curtis K

Hi! My name is Curtis, and I am the author of CentOS Blog. Please feel free to comment with any suggestions, feedback or questions!