Linux provides three useful memory metrics:

  • RSS (Resident Set Size): Shows the total memory currently in RAM that a process is using, including both shared and private memory pages.
  • PSS (Proportional Set Size): Shows the process's private memory plus its proportional share of shared memory. For example, if 10 processes share 20 MB of memory equally, each process is counted as using 2 MB of that shared memory.
  • USS (Unique Set Size): Shows only the memory in RAM that belongs exclusively to a process and is not shared with other processes.

Why Does Shared Memory Matter?

Multiple processes can use the same physical memory pages. For example, they may share executable code, libraries, or other read-only data instead of keeping separate physical copies.

Each process still needs its own memory for variables, execution state, and other private data.

Because RSS includes shared memory, adding the RSS values of multiple processes can count the same physical memory more than once. This can make the total appear higher than the actual physical RAM being used.

Which Metric Should You Use?

Use RSS to check how much resident memory is mapped by an individual process.

Use PSS to estimate the memory used by a group of processes without counting shared pages in full for every process.

Use USS to understand how much resident memory is unique to an individual process.

For accurate memory analysis, PSS is often a useful metric when comparing groups of processes. USS is helpful when investigating private memory usage.

Practical Example: Check Memory Usage on Linux

You can use the smem tool to view RSS, PSS, and USS for running processes.

Step 1: Install smem

code
sudo apt update
sudo apt install smem

Step 2: Display memory usage for all processes

code
sudo smem

The output includes columns such as:

  • RSS: Resident memory, including shared pages.
  • PSS: Resident memory with shared pages divide proportionally.
  • USS: Resident memory unique to each process.

Step 3: Check a specific process

For example, to inspect Node.js processes:

code
sudo smem -P 'php'

Step 4: Compare total memory usage

To display a summary of memory usage by process, you can use:

sudo smem -t
sudo smem -t