Skip to content

Understanding the top commands' memory type fields

Introduction

When memory becomes scarce, the top command offers great visibility over the systems' memory resources which can help in identifying which processes are creating the bottleneck. However, the output can be overwhelming and confusing when the column label definitions are not known or clear.

Below is a list of the most important and useful definitions that describe the various memory types and metrics generated by the top command in a GNU/Linux system.

Definitions

RES

A subset of the virtual address space (VIRT) representing the non-swapped physical memory a task is currently using.

%MEM

Simply RES divided by total physical memory.

SWAP

The formerly resident portion of a task's address space written to the swap file when physical memory becomes over committed.

USED

This field represents the non-swapped physical memory a task is using (RES) plus the swapped out portion of its address space (SWAP).

CODE

The amount of physical memory currently devoted to executable code, also known as the Text Resident Set size or TRS.

DATA

The amount of private memory reserved by a process. It is also known as the Data Resident Set or DRS. Such memory may not yet be mapped to physical memory (RES) but will always be included in the virtual memory (VIRT) amount.

RSS

Another, more precise view of process non-swapped physical memory. It is obtained from the smaps_rollup file and is generally slightly larger than that shown for (RES).

Note that this also accounts for the non-swapped shared memory pages, e.g. shared libraries.

USS

The non-swapped portion of physical memory (RSS) NOT SHARED with any other process.

VIRT

The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used.

SHR

A subset of resident memory (RES) that may be used by other processes. It will include shared anonymous pages and shared file-backed pages. It also includes private pages mapped to files representing program images and shared libraries.