Master Linux Memory Insights with smem: Install, Use, and Visualize
This guide explains how to install the Linux smem tool, use its various options to report RSS, USS, and PSS memory metrics, filter results for specific processes or users, and generate visual pie and bar charts with Python's matplotlib for clearer memory analysis.
1. Install smem
On Fedora (19+) the package is in the default repositories; install with yum: $ sudo yum install smem On Ubuntu use apt-get: $ sudo apt-get install smem If the package is unavailable, download the source from https://www.selenic.com/smem/download/ and compile manually.
2. Common smem usage
Running smem without arguments lists each running process with memory consumption, showing RSS, USS, and PSS. PSS (Proportional Set Size) gives a fairer measurement for shared memory. $ smem Show memory used by each shared library (output can be long): $ smem -m Filter for a specific application (e.g., Firefox) and display percentages: $ smem -m -p | grep firefox Show memory usage per user: $ smem -u -p Display overall system memory statistics:
$ smem -w -p3. Visualizing results
Python’s matplotlib library can turn the numeric tables into charts. Install it first:
# Fedora
$ sudo yum install python-matplotlib
# Ubuntu
$ sudo apt-get install python-matplotlib3.1 Pie chart
Generate a pie chart by adding the --pie option and selecting the metric with -s (e.g., pss, uss, or rss). $ smem --pie name -s pss Replace pss with uss or rss to view those metrics.
3.2 Bar chart
Use the --bar option to produce a bar chart that simultaneously shows USS, PSS, and RSS values. The following command displays the data per process ID: $ smem --bar pid -c "pss uss rss" Replace pid with name to label bars by process name.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
