smem
Report memory usage per process
TLDR
Print memory usage for current processes
Print memory usage for current processes for a every user on a system
Print memory usage for current processes for a specified user
Print system memory information
SYNOPSIS
smem [OPTIONS]
PARAMETERS
-t
Display totals for all memory columns at the end of the report.
-s KEY
Sort the output by a specified column key. Common keys include 'pss', 'rss', 'uss', 'name', or 'pid'.
-k
Output memory sizes in kilobytes (KB). This is the default unit.
-m
Output memory sizes in megabytes (MB).
-g
Output memory sizes in gigabytes (GB).
-p
Display memory sizes as percentages of total system memory.
-c COLUMNS
Specify a comma-separated list of columns to display. Examples: 'pid,user,command,pss,rss,uss'.
-P PATTERN
Filter processes by a regular expression pattern matching the command name.
-u PATTERN
Filter processes by a regular expression pattern matching the username.
--group
Group processes by their command name, showing combined memory usage for each group.
--user-group
Group processes by user, showing combined memory usage for each user.
--abbrev
Abbreviate long command names for cleaner output.
-V
Display the version information of smem.
-h
Display the help message and exit.
DESCRIPTION
smem is a command-line utility designed to report physical memory usage on a Linux system, with a particular focus on accurately accounting for shared memory.
Unlike traditional tools like ps or top, which often over-report memory usage by counting shared pages multiple times, smem introduces the concept of Proportional Set Size (PSS).
It provides three key memory metrics:
- RSS (Resident Set Size): The total physical memory used by a process, including shared libraries. Shared memory is counted for each process that uses it.
- USS (Unique Set Size): The amount of physical memory that is exclusively used by a process and not shared with any other process.
- PSS (Proportional Set Size): The total physical memory used by a process, where shared memory is divided proportionally among the processes that use it. PSS is generally considered the most accurate representation of a process's actual memory footprint.
It allows for flexible output formatting, filtering by process name or user, and sorting results based on various memory metrics.
CAVEATS
smem typically requires root privileges or appropriate permissions to access comprehensive memory information for all processes on the system.
It can be more resource-intensive than simpler tools like ps or top, especially on systems with a very large number of processes, as it gathers detailed per-process memory statistics.
smem may not be pre-installed on all Linux distributions and might require installation via the distribution's package manager.
UNDERSTANDING PSS, RSS, AND USS
The distinction between PSS, RSS, and USS is fundamental to understanding smem's value.
RSS (Resident Set Size) is straightforward: it's the total memory a process has in RAM, including shared pages. However, summing RSS values across all processes can lead to greatly inflated total memory usage because shared pages are counted for every process that uses them.
USS (Unique Set Size) is the opposite extreme: it only counts memory pages that are exclusive to a process, ignoring all shared memory.
PSS (Proportional Set Size) strikes a balance. It allocates shared memory pages proportionally among the processes that share them. For example, if two processes share a 10MB page, each process's PSS would include 5MB of that page. This makes PSS the most accurate metric for understanding a process's true contribution to overall system memory consumption, as summing PSS values for all processes will approximate the total physical memory in use.
HISTORY
The smem utility was developed to address a significant limitation in traditional Linux memory reporting tools (like ps and top) which often overestimate total memory usage due to their simplistic handling of shared memory.
It introduces the Proportional Set Size (PSS) metric, offering a more accurate and realistic view of how much physical RAM processes genuinely consume.
Part of the `smem` project, it has been a valuable tool for detailed memory analysis in Linux environments since its inception, providing insights crucial for performance tuning and resource management.