smem – Linux Memory Reporting/Statistics Tool

Monitoring memory utilization on Linux box is one of the important task for Linux Administrator to make the system up and running smoothly. There are plenty of commands/tools are available to monitor memory utilization on Linux, each one is working in different manner, today we are going to show you
about smem.

smem is a tool that can give numerous reports on memory usage on Linux systems. Unlike existing tools, smem can report Proportional Set Size (PSS), Unique Set Size (USS) & Resident Set Size (RSS).

Proportional Set Size (PSS) : Representation of the amount of memory used by libraries and applications in a virtual memory system.

Unique Set Size (USS) : Unshared memory is reported as the USS (Unique Set Size).

Resident Set Size (RSS) : The standard measure of physical memory (it typically shared among multiple applications) usage known as resident set size (RSS) will significantly overestimate memory usage.

The USS and PSS only include physical memory usage. They do not include memory that has been swapped out to disk. Memory can be reported by process, by user, by mapping, or system wide and possible to get the output via text mode and graphical mode.

PSS measures each applications & libraries fair share memory for realistic measure. It pull most of the data from the /proc file system.

smem has a utility called smemcap which used to capture memory statistics on running systems. smemcap captures all /proc entries required by smem and store the data as a uncompressed .tar file. smem can analyze the output using the –source option.

By default most of the modern system fulfill the basic requirements for smem like kernel (> 2.6.27) & Python (2.4 or later) except matplotlib library package for chart generation that to for optional.

smem features

  • system overview listing
  • listings by process, mapping, user
  • filtering by process, mapping, or user
  • configurable columns from multiple data sources
  • configurable output units and percentages
  • configurable headers and totals
  • reading live data from /proc
  • reading data snapshots from directory mirrors or compressed tarballs
  • lightweight capture tool for embedded systems
  • built-in chart generation

Install smem in Linux

Most of the distributions (Debian, Ubuntu, Mint, Fedora, suse, openSUSE, Arch Linux, Manjaro, Mageia, etc.) has the smem package so, we can easily install it from distribution official repository. For RHEL/CentOS enable epel repository.

[Install smem on CentOS/RHEL]
$ sudo yum install smem
$ sudo yum install python-matplotlib

[Install smem on Fedora]
$ sudo dnf install smem
$ sudo dnf install python-matplotlib

[Install smem on Debian/Ubuntu]
$ sudo apt-get install smem
$ sudo apt-get install python-matplotlib

[Install smem on Arch Linux]
$ sudo pacman -S smem
$ sudo pacman -S python2-matplotlib

[Install smem on Mageia]
$ sudo urpmi smem
$ sudo urpmi python-matplotlib

[Install smem on openSUSE]
$ sudo zypper install smem
$ sudo zypper install python-matplotlib

Run smem without any options

After successfully smem installed with help of above command. Just fire the below command on terminal to mesure memory usage.

# smem

  PID User     Command                         Swap      USS      PSS      RSS
 7510 root     /sbin/mingetty /dev/tty1           0       72       89      540
 7518 root     /sbin/mingetty /dev/tty4           0       72       89      540
 7524 root     /sbin/mingetty /dev/tty5           0       72       89      540
 7526 root     /sbin/mingetty /dev/tty6           0       72       89      540
 7514 root     /sbin/mingetty /dev/tty2           0       76       93      544
 7516 root     /sbin/mingetty /dev/tty3           0       76       93      544
 2487 root     /sbin/portreserve                  0      104      122      584
 7278 root     /usr/sbin/mcelog --daemon          0      128      131      272
 2685 root     /usr/sbin/acpid                    0      172      189      536
 7460 root     /usr/bin/rhsmcertd                 0      156      216      616
 7444 root     /usr/sbin/atd                      0      212      224      500
21554 root     /sbin/udevd -d                     0       92      227      720
 2743 haldaemon hald-addon-acpi: listening         0      156      238     1040
21553 root     /sbin/udevd -d                     0      100      243      760
 1168 root     /sbin/udevd -d                     0      108      253      852
 2730 root     hald-addon-input: Listening        0      176      301     1072
 2698 root     hald-runner                        0      220      354     1180
 2463 root     auditd                             0      344      362      836
 2591 rpc      rpcbind                            0      312      368      896
 2573 root     irqbalance --pid=/var/run/i        0      464      490      924
 2613 rpcuser  rpc.statd                          0      516      586     1308
 2647 dbus     dbus-daemon --system               0      592      615     1004
    1 root     /sbin/init                         0      556      638     1520
 7429 root     crond                              0      684      713     1276
21729 root     /sbin/dhclient -H 2daygeeks        0      732      744     1024
 7295 root     /usr/sbin/sshd                     0      728      785     1248
28150 zenoss   sshd: [email protected]                  0      340      948     2116
10364 nobody   /usr/bin/nmon -f -t -m /var        0      932      965     1328
 7477 root     /usr/sbin/certmonger -S -p         0      960      994     1452
 2768 root     automount --pid-file /var/r        0     1028     1085     1816
20091 root     -bash                              0     1124     1205     1928
 7415 root     /usr/libexec/postfix/master        0     1032     1524     3440
28148 root     sshd: zenoss [priv                 0      220     1604     4524
29914 postfix  pickup -l -t fifo -u               0     1228     1604     3416
 7422 postfix  qmgr -l -t fifo -u                 0     1140     1636     3556
20087 root     sshd: [email protected]/0                   0     1400     2409     4956
 2697 haldaemon hald                               0     3132     3303     4380
 2497 root     /sbin/rsyslogd -i /var/run/        0     3360     3392     4000
31076 root     python /usr/bin/smem               0     6360     6418     7112

Show the output in MB

By default memory usage output shows on KB which may get confuse, add k option with smem to get the ouput in MB.

# smem -k

  PID User     Command                         Swap      USS      PSS      RSS
 7510 root     /sbin/mingetty /dev/tty1           0    72.0K    89.0K   540.0K
 7518 root     /sbin/mingetty /dev/tty4           0    72.0K    89.0K   540.0K
 7524 root     /sbin/mingetty /dev/tty5           0    72.0K    89.0K   540.0K
 7526 root     /sbin/mingetty /dev/tty6           0    72.0K    89.0K   540.0K
 7514 root     /sbin/mingetty /dev/tty2           0    76.0K    93.0K   544.0K
 7516 root     /sbin/mingetty /dev/tty3           0    76.0K    93.0K   544.0K
 2487 root     /sbin/portreserve                  0   104.0K   122.0K   584.0K
 7278 root     /usr/sbin/mcelog --daemon          0   128.0K   131.0K   272.0K
 2685 root     /usr/sbin/acpid                    0   172.0K   189.0K   536.0K
 7460 root     /usr/bin/rhsmcertd                 0   156.0K   216.0K   616.0K
 7444 root     /usr/sbin/atd                      0   212.0K   224.0K   500.0K
21554 root     /sbin/udevd -d                     0    92.0K   227.0K   720.0K
 2743 haldaemon hald-addon-acpi: listening         0   156.0K   238.0K     1.0M
21553 root     /sbin/udevd -d                     0   100.0K   243.0K   760.0K
 1168 root     /sbin/udevd -d                     0   108.0K   253.0K   852.0K
 2730 root     hald-addon-input: Listening        0   176.0K   301.0K     1.0M
 2698 root     hald-runner                        0   220.0K   354.0K     1.2M
 2463 root     auditd                             0   344.0K   362.0K   836.0K
 2591 rpc      rpcbind                            0   312.0K   368.0K   896.0K
 2573 root     irqbalance --pid=/var/run/i        0   464.0K   490.0K   924.0K
 2613 rpcuser  rpc.statd                          0   516.0K   586.0K     1.3M
 2647 dbus     dbus-daemon --system               0   592.0K   615.0K  1004.0K
    1 root     /sbin/init                         0   556.0K   638.0K     1.5M
 7429 root     crond                              0   684.0K   713.0K     1.2M
21729 root     /sbin/dhclient -H 2daygeeks        0   732.0K   744.0K     1.0M
 7295 root     /usr/sbin/sshd                     0   728.0K   785.0K     1.2M
28150 zenoss   sshd: [email protected]                  0   340.0K   948.0K     2.1M
10364 nobody   /usr/bin/nmon -f -t -m /var        0   932.0K   965.0K     1.3M
 7477 root     /usr/sbin/certmonger -S -p         0   960.0K   994.0K     1.4M
 2768 root     automount --pid-file /var/r        0     1.0M     1.1M     1.8M
20091 root     -bash                              0     1.1M     1.2M     1.9M
 7415 root     /usr/libexec/postfix/master        0     1.0M     1.5M     3.4M
28148 root     sshd: zenoss [priv                 0   220.0K     1.6M     4.4M
29914 postfix  pickup -l -t fifo -u               0     1.2M     1.6M     3.3M
 7422 postfix  qmgr -l -t fifo -u                 0     1.1M     1.6M     3.5M
20087 root     sshd: [email protected]/0                   0     1.4M     2.4M     4.8M
 2697 haldaemon hald                               0     3.1M     3.2M     4.3M
 2497 root     /sbin/rsyslogd -i /var/run/        0     3.3M     3.3M     3.9M
32131 root     python /usr/bin/smem -k            0     6.2M     6.3M     6.9M

show total memory usage

Even the output shows in MB, to get the total memory with smem, add t option.

# smem -tk

  PID User     Command                         Swap      USS      PSS      RSS
 7510 root     /sbin/mingetty /dev/tty1           0    72.0K    89.0K   540.0K
 7518 root     /sbin/mingetty /dev/tty4           0    72.0K    89.0K   540.0K
 7524 root     /sbin/mingetty /dev/tty5           0    72.0K    89.0K   540.0K
 7526 root     /sbin/mingetty /dev/tty6           0    72.0K    89.0K   540.0K
 7514 root     /sbin/mingetty /dev/tty2           0    76.0K    93.0K   544.0K
 7516 root     /sbin/mingetty /dev/tty3           0    76.0K    93.0K   544.0K
 2487 root     /sbin/portreserve                  0   104.0K   122.0K   584.0K
 7278 root     /usr/sbin/mcelog --daemon          0   128.0K   131.0K   272.0K
 2685 root     /usr/sbin/acpid                    0   172.0K   189.0K   536.0K
 7460 root     /usr/bin/rhsmcertd                 0   156.0K   216.0K   616.0K
 7444 root     /usr/sbin/atd                      0   212.0K   224.0K   500.0K
21554 root     /sbin/udevd -d                     0    92.0K   227.0K   720.0K
 2743 haldaemon hald-addon-acpi: listening         0   156.0K   238.0K     1.0M
21553 root     /sbin/udevd -d                     0   100.0K   243.0K   760.0K
 1168 root     /sbin/udevd -d                     0   108.0K   253.0K   852.0K
 2730 root     hald-addon-input: Listening        0   176.0K   301.0K     1.0M
 2698 root     hald-runner                        0   220.0K   354.0K     1.2M
 2463 root     auditd                             0   344.0K   362.0K   836.0K
 2591 rpc      rpcbind                            0   312.0K   368.0K   896.0K
 2573 root     irqbalance --pid=/var/run/i        0   464.0K   490.0K   924.0K
 2613 rpcuser  rpc.statd                          0   516.0K   586.0K     1.3M
 2647 dbus     dbus-daemon --system               0   592.0K   615.0K  1004.0K
    1 root     /sbin/init                         0   556.0K   638.0K     1.5M
 7429 root     crond                              0   684.0K   713.0K     1.2M
21729 root     /sbin/dhclient -H 2daygeeks        0   732.0K   744.0K     1.0M
 7295 root     /usr/sbin/sshd                     0   728.0K   785.0K     1.2M
28150 zenoss   sshd: [email protected]                  0   340.0K   948.0K     2.1M
10364 nobody   /usr/bin/nmon -f -t -m /var        0   932.0K   965.0K     1.3M
 7477 root     /usr/sbin/certmonger -S -p         0   960.0K   994.0K     1.4M
 2768 root     automount --pid-file /var/r        0     1.0M     1.1M     1.8M
20091 root     -bash                              0     1.1M     1.2M     1.9M
 7415 root     /usr/libexec/postfix/master        0     1.0M     1.5M     3.4M
28148 root     sshd: zenoss [priv                 0   220.0K     1.6M     4.4M
29914 postfix  pickup -l -t fifo -u               0     1.2M     1.6M     3.3M
 7422 postfix  qmgr -l -t fifo -u                 0     1.1M     1.6M     3.5M
20087 root     sshd: [email protected]/0                   0     1.4M     2.4M     4.8M
 2697 haldaemon hald                               0     3.1M     3.2M     4.3M
 2497 root     /sbin/rsyslogd -i /var/run/        0     3.3M     3.3M     3.9M
32132 root     python /usr/bin/smem -tk           0     6.2M     6.3M     6.9M
-------------------------------------------------------------------------------
   39 8                                           0    28.6M    34.6M    63.9M

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...

Close
Please support the site
By clicking any of these buttons you help our site to get better