Smem – Show Linux Memory Usage on Per-Process and Per-User

Memory management, particularly monitoring memory usage, is crucial for your Linux system. There are many tools available across different Linux distributions to monitor memory usage, each functioning in distinct ways.

In this how-to guide, we will explore a smem reporting tool that can help you report memory consumption on a per-process and per-user basis in a Linux environment.

How to Install Smem – Memory Reporting Tool in Linux

smem is a command-line memory reporting tool that gives a user diverse reports on memory usage on a Linux system. There is one unique thing about smem, unlike other traditional memory reporting tools, it reports PSS (Proportional Set Size), a more meaningful representation of memory usage by applications and libraries in a virtual memory setup.

Existing traditional tools focus mainly on reading RSS (Resident Set Size) which is a standard measure to monitor memory usage in a physical memory scheme, but tends to overestimate memory usage by applications.

PSS on the other hand, gives a reasonable measure by determining the “fair-share” of memory used by applications and libraries in a virtual memory scheme.

Features of smem tool:

  • System overview listing
  • Listings and also filtering by process, mappings or user
  • Using data from /proc filesystem
  • Configurable listing columns from several data sources
  • Configurable output units and percentages
  • Easy to configure headers and totals in listings
  • Using data snapshots from directory mirrors or compressed tar files
  • Built-in chart generation mechanism
  • Lightweight capture tool used in embedded systems

Install Smem in Linux

To install GIMP on Linux, use the following appropriate command for your specific Linux distribution.

sudo apt install smem         [On Debian, Ubuntu and Mint]
sudo yum install smem         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/smem  [On Gentoo Linux]
sudo apk add smem             [On Alpine Linux]
sudo pacman -S smem           [On Arch Linux]
sudo zypper install smem      [On OpenSUSE]    
sudo pkg install smem         [On FreeBSD]

Display Linux Memory Usage Statistics

To view a report of memory usage across the whole system, by all system users, run the following command:

sudo smem
Smem - Memory Reporting Tool
Smem – Memory Reporting Tool

When a normal user runs smem, it displays memory usage by a process that the user has started, the processes are arranged in order of increasing PSS.

Take a look at the output below on my system for memory usage by processes started by the user tecmint:

smem
Monitor User Memory Usage by Processes
Monitor User Memory Usage by Processes

There are many options to invoke while using smem, for example, to view system-wide memory consumption, run the following command:

sudo smem -w
Check System Wide Memory Consumption
Check System-Wide Memory Consumption

Display Memory Usage Per User in Linux

To view memory usage on a per-user basis, run the command below:

sudo smem -u
Check Memory Usage Per User Basis
Check Memory Usage Per User Basis

You can also report memory usage statistics by mappings as follows:

sudo smem -m
Check Memory Usage Statistics
Check Memory Usage Statistics

Display Memory Usage Per Processes in Linux

To filter output by process name, invoke the -P or --processfilter="regex" option as follows:

sudo smem --processfilter="chrome"
ChecK Memory Usage by Processes
Check Memory Usage by Processes

Output formatting can be very important, and there are options to help you format memory reports we shall look at a few examples below.

To show desired columns in the report, use -c or --columns option as follows:

sudo smem -c "name user pss rss"
Display Memory Usage with Specific Columns
Display Memory Usage with Specific Columns

You can invoke the -p option to report memory usage in percentages, as in the command below:

sudo smem -p
Display Memory Usage in Percentage
Display Memory Usage in Percentage

The command below will show totals at the end of each column of the output:

sudo smem -t

Display Visual Representation of Memory Usage

Furthermore, there are options for graphical reports that you can also use and we shall dive into them in this sub-section.

You can produce a bar graph of processes and their PSS and RSS values, in the example below, we produce a bar graph of processes owned by the root user.

The vertical plane shows the PSS and RSS measure of processes and the horizontal plane represents each root user process:

sudo smem --userfilter="root" --bar pid -c"pss rss"
Linux Memory Usage in PSS and RSS Values
Linux Memory Usage in PSS and RSS Values

You can also produce a pie chart showing processes and their memory consumption based on PSS or RSS values. The command below outputs a pie chart for processes owned by the root user measuring values.

The --pie name means label by name and -s option helps to sort by PSS value.

sudo smem --userfilter="root" --pie name -s pss
Linux Memory Consumption by Processes
Linux Memory Consumption by Processes

There are many other known fields apart from PSS and RSS used for labeling charts:

To get help, simply type, smem -h or visit the manual entry page.

smem -h

We shall stop here with smem, but to understand it better, use it with many other options that you can find on the man page. You can use the comment section below to express any thoughts or concerns.

Similar Posts