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 
 2054 magi     sleep infinity                    80        4       10      740 
 1864 magi     sleep infinity                    80        4       11      764 
 2416 magi     /usr/lib/gvfs/gvfs-goa-volu      612        4       22     2168 
 1698 magi     /usr/lib/gvfs/gvfsd-fuse /r      788        4       23     2236 
 2248 magi     /usr/lib/x86_64-linux-gnu/i      716        4       24     2284 
 2401 magi     /usr/lib/gvfs/gvfs-afc-volu     1188        4       24     2356 
 2439 magi     /usr/lib/gvfs/gvfs-mtp-volu      644        4       25     2276 
 2247 magi     /usr/lib/x86_64-linux-gnu/i     3028        4       27     2484 
 1820 magi     /usr/lib/at-spi2-core/at-sp     2724        4       28     2428 
 2424 magi     /usr/lib/gvfs/gvfs-gphoto2-      784        8       29     2384 
 2403 magi     /usr/lib/evolution/evolutio     3216        4       30     2624 
 2405 magi     /usr/lib/evolution/evolutio     5048        4       30     2672 
 1690 magi     /usr/lib/dconf/dconf-servic      744       16       34     2164 
 2382 magi     /usr/lib/evolution/evolutio     5324        4       34     2816 
 2435 magi     /usr/lib/evolution/evolutio     3332        4       42     2836 
 2383 magi     /usr/lib/gvfs/gvfs-udisks2-     1660        4       43     2620 
 3574 magi     sleep 2h                          44       44       51      832 
 2350 magi     /usr/lib/evolution/evolutio     6560        4       54     3572 
 2542 magi     /bin/sh -c /usr/lib/x86_64-       88        4       56      848 
 2339 magi     sh /home/magi/.config/ukuu-       88        4       57      936 
 1871 magi     /bin/sh -e /proc/self/fd/9        84        4       58      964 
 1880 magi     /usr/lib/x86_64-linux-gnu/u     2504        4       65     2720 
 1693 magi     /usr/lib/gvfs/gvfsd              764       84      125     2376 
 2471 magi     /usr/bin/redshift -v             360      132      157     2324 
 1891 magi     upstart-dbus-bridge --daemo      180      140      169      880 
 1767 magi     /usr/bin/xbrlapi -q              460      184      202     1776 
 1909 magi     upstart-file-bridge --daemo      444      204      218      856 
 3821 magi     /usr/lib/gvfs/gvfsd-dnssd -      764      196      226     2736 
 4175 magi     /bin/bash /usr/bin/battery-        0      220      227     1128 
 1893 magi     upstart-dbus-bridge --daemo      236      236      267     1116 
 1868 magi     upstart-udev-bridge --daemo      184      244      294     1380 
 3632 magi     /usr/lib/x86_64-linux-gnu/g      404      308      333     2444 
 1825 magi     /usr/bin/dbus-daemon --conf      272      308      365     1924 
 1827 magi     /usr/lib/at-spi2-core/at-sp     2444      372      400     2992 
 2168 magi     /usr/lib/ibus/ibus-dconf         324      380      407     2708 
 3412 magi     /usr/lib/x86_64-linux-gnu/d      704      384      408     2848 
 2493 magi     /usr/lib/gvfs/gvfsd-metadat      256      404      423     2644 
 2232 magi     /usr/lib/ibus/ibus-engine-s      288      456      486     2864 
 2298 magi     /usr/lib/x86_64-linux-gnu/i     1180      464      527     4040 
 3803 magi     /usr/lib/gvfs/gvfsd-network      460      648      766     3292 
 1639 magi     /lib/systemd/systemd --user      852      524      783     2788 
 2262 magi     /usr/lib/x86_64-linux-gnu/i      312      740      865     3472 
 2278 magi     /usr/lib/x86_64-linux-gnu/i     2468      852      872     3132

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 
 2054 magi     sleep infinity                 80.0K     4.0K    10.0K   740.0K 
 1864 magi     sleep infinity                 80.0K     4.0K    11.0K   764.0K 
 1698 magi     /usr/lib/gvfs/gvfsd-fuse /r   788.0K     4.0K    22.0K     2.1M 
 2416 magi     /usr/lib/gvfs/gvfs-goa-volu   612.0K     4.0K    22.0K     2.1M 
 2248 magi     /usr/lib/x86_64-linux-gnu/i   716.0K     4.0K    23.0K     2.2M 
 2401 magi     /usr/lib/gvfs/gvfs-afc-volu     1.2M     4.0K    24.0K     2.3M 
 2439 magi     /usr/lib/gvfs/gvfs-mtp-volu   644.0K     4.0K    24.0K     2.2M 
 2247 magi     /usr/lib/x86_64-linux-gnu/i     3.0M     4.0K    26.0K     2.4M 
 1820 magi     /usr/lib/at-spi2-core/at-sp     2.7M     4.0K    27.0K     2.3M 
 2403 magi     /usr/lib/evolution/evolutio     3.1M     4.0K    28.0K     2.5M 
 2405 magi     /usr/lib/evolution/evolutio     4.9M     4.0K    28.0K     2.5M 
 2424 magi     /usr/lib/gvfs/gvfs-gphoto2-   784.0K     8.0K    29.0K     2.3M 
 2382 magi     /usr/lib/evolution/evolutio     5.2M     4.0K    32.0K     2.7M 
 1690 magi     /usr/lib/dconf/dconf-servic   744.0K    16.0K    34.0K     2.1M 
 2435 magi     /usr/lib/evolution/evolutio     3.3M     4.0K    38.0K     2.7M 
 2383 magi     /usr/lib/gvfs/gvfs-udisks2-     1.6M     4.0K    42.0K     2.5M 
 3574 magi     sleep 2h                       44.0K    44.0K    51.0K   832.0K 
 2350 magi     /usr/lib/evolution/evolutio     6.4M     4.0K    52.0K     3.4M 
 2542 magi     /bin/sh -c /usr/lib/x86_64-    88.0K     4.0K    56.0K   848.0K 
 2339 magi     sh /home/magi/.config/ukuu-    88.0K     4.0K    57.0K   936.0K 
 1871 magi     /bin/sh -e /proc/self/fd/9     84.0K     4.0K    58.0K   964.0K 
 1880 magi     /usr/lib/x86_64-linux-gnu/u     2.4M     4.0K    63.0K     2.6M 
 1693 magi     /usr/lib/gvfs/gvfsd           764.0K    56.0K    83.0K     2.2M 
 2471 magi     /usr/bin/redshift -v          360.0K   132.0K   157.0K     2.3M 
 1891 magi     upstart-dbus-bridge --daemo   180.0K   140.0K   169.0K   880.0K 
 1767 magi     /usr/bin/xbrlapi -q           460.0K   184.0K   201.0K     1.7M 
 1909 magi     upstart-file-bridge --daemo   444.0K   204.0K   218.0K   856.0K 
 3821 magi     /usr/lib/gvfs/gvfsd-dnssd -   764.0K   196.0K   225.0K     2.6M 
 4175 magi     /bin/bash /usr/bin/battery-        0   220.0K   227.0K     1.1M 
 1893 magi     upstart-dbus-bridge --daemo   236.0K   236.0K   267.0K     1.1M 
 1868 magi     upstart-udev-bridge --daemo   184.0K   244.0K   294.0K     1.3M 
 3632 magi     /usr/lib/x86_64-linux-gnu/g   404.0K   308.0K   333.0K     2.4M 
 1825 magi     /usr/bin/dbus-daemon --conf   272.0K   308.0K   365.0K     1.9M 
 1827 magi     /usr/lib/at-spi2-core/at-sp     2.4M   372.0K   400.0K     2.9M 
 3412 magi     /usr/lib/x86_64-linux-gnu/d   704.0K   384.0K   405.0K     2.7M 
 2168 magi     /usr/lib/ibus/ibus-dconf      324.0K   380.0K   407.0K     2.6M 
 2493 magi     /usr/lib/gvfs/gvfsd-metadat   256.0K   396.0K   415.0K     2.5M 
 2232 magi     /usr/lib/ibus/ibus-engine-s   288.0K   456.0K   485.0K     2.8M 
 2298 magi     /usr/lib/x86_64-linux-gnu/i     1.2M   464.0K   526.0K     3.9M 
 3803 magi     /usr/lib/gvfs/gvfsd-network   468.0K   552.0K   572.0K     2.9M 
 1639 magi     /lib/systemd/systemd --user   852.0K   524.0K   714.0K     2.6M 
 2278 magi     /usr/lib/x86_64-linux-gnu/i     2.4M   716.0K   734.0K     2.9M 
 1875 magi     /usr/lib/x86_64-linux-gnu/h   520.0K   420.0K   827.0K     3.0M 
 2262 magi     /usr/lib/x86_64-linux-gnu/i   312.0K   716.0K   850.0K     3.3M 
 2271 magi     /usr/lib/x86_64-linux-gnu/i     2.8M   828.0K   992.0K     4.0M 
 2115 magi     /usr/lib/gnome-session/gnom     1.5M   980.0K     1.0M     4.3M 
 1728 magi     /sbin/upstart --user          420.0K     1.1M     1.1M     2.6M 

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 
 2054 magi     sleep infinity                 80.0K     4.0K    10.0K   740.0K 
 1864 magi     sleep infinity                 80.0K     4.0K    11.0K   764.0K 
 1698 magi     /usr/lib/gvfs/gvfsd-fuse /r   788.0K     4.0K    22.0K     2.1M 
 2416 magi     /usr/lib/gvfs/gvfs-goa-volu   612.0K     4.0K    22.0K     2.1M 
 2248 magi     /usr/lib/x86_64-linux-gnu/i   716.0K     4.0K    23.0K     2.2M 
 2401 magi     /usr/lib/gvfs/gvfs-afc-volu     1.2M     4.0K    24.0K     2.3M 
 2439 magi     /usr/lib/gvfs/gvfs-mtp-volu   644.0K     4.0K    24.0K     2.2M 
 2247 magi     /usr/lib/x86_64-linux-gnu/i     3.0M     4.0K    26.0K     2.4M 
 4193 magi     bash                               0     2.7M     2.7M     3.7M 
 2152 magi     /usr/bin/ibus-daemon --daem   920.0K     2.7M     2.7M     5.1M 
 2186 magi     /usr/lib/ibus/ibus-x11 --ki     3.4M     2.6M     2.8M     8.1M 
 2320 magi     /usr/lib/unity-settings-dae     3.2M     2.7M     2.9M     8.0M 
 2273 magi     /usr/lib/x86_64-linux-gnu/i     4.0M     2.7M     2.9M     8.3M 
 2325 magi     nm-applet                       3.9M     2.7M     2.9M     8.6M 
 2237 magi     /usr/bin/pulseaudio --start     1.2M     2.9M     3.2M     5.6M 
 2280 magi     /usr/lib/policykit-1-gnome/     2.2M     3.6M     3.7M     8.9M 
 2621 magi     update-notifier                 1.8M     4.3M     4.6M    11.2M 
 2180 magi     /usr/lib/ibus/ibus-ui-gtk3      3.2M     4.7M     5.0M    11.4M 
 3421 magi     /usr/lib/x86_64-linux-gnu/u     3.4M     5.4M     5.4M     8.0M 
 1819 magi     /usr/lib/x86_64-linux-gnu/n     1.7M     5.8M     6.1M    12.8M 
 2270 magi     /usr/lib/x86_64-linux-gnu/i     2.0M     6.1M     6.3M    11.7M 
 2103 magi     /usr/lib/unity-settings-dae     3.3M     5.9M     6.4M    13.0M 
 3431 magi     /usr/bin/unity-scope-loader     2.2M     6.6M     6.6M     9.4M 
 2337 magi     /usr/bin/python3 /usr/bin/r    10.4M     6.2M     6.8M    12.9M 
 4176 magi     python3 /usr/share/battery-        0     7.8M     8.2M    11.0M 
 1900 magi     /usr/lib/x86_64-linux-gnu/b     1.8M     8.0M     8.2M    14.1M 
 2042 magi     /usr/lib/x86_64-linux-gnu/h     3.5M     9.4M     9.9M    13.1M 
 5546 magi     /usr/bin/python /usr/bin/sm        0    13.1M    13.2M    14.5M 
 4073 magi     /usr/lib/gnome-terminal/gno        0    12.2M    13.9M    22.0M 
 2299 magi     /usr/bin/gnome-software --g    54.4M    14.8M    15.0M    20.6M 
 2214 magi     /usr/lib/x86_64-linux-gnu/u     1.2M    15.9M    16.6M    23.8M 
 2300 magi     nautilus -n                     6.2M    17.2M    18.7M    27.1M 
 3459 magi     inkscape                       66.6M    69.7M    70.8M    76.8M 
 3937 magi     /usr/bin/perl /usr/bin/shut    35.5M    80.5M    83.2M    91.2M 
 2202 magi     /usr/bin/compiz               102.8M   186.4M   188.4M   197.7M 
 3593 magi     /usr/lib/firefox/firefox       48.2M   174.9M   221.6M   275.5M 
 3694 magi     /usr/lib/firefox/plugin-con    12.0M   854.8M   892.6M   937.2M 
-------------------------------------------------------------------------------
   84 1                                      450.2M     1.5G     1.6G     2.0G

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