Commands.page Logo

Understanding SHR vs RES Columns in htop on Ubuntu

When monitoring system performance on Ubuntu using htop, understanding memory metrics is crucial for identifying resource hogs. This article explains the specific differences between the SHR and RES columns, detailing how shared memory and resident memory are calculated and displayed. By the end, you will know exactly what each value represents regarding your running processes.

RES (Resident Memory) The RES column displays the total physical RAM currently used by a process. This value encompasses all memory pages stored in RAM, including both private memory exclusive to the process and any shared memory it is accessing. It excludes memory that has been swapped out to the disk, representing the actual hardware memory footprint of the task.

SHR (Shared Memory) The SHR column indicates the portion of the RES value that is shared with other processes. This memory typically consists of shared libraries, code segments, and memory-mapped files that multiple applications utilize simultaneously. It is always a subset of the resident memory value.

The Key Difference The distinction lies in exclusivity. RES measures the total physical memory occupied, while SHR measures only the part of that memory shared across the system. To calculate the private memory usage dedicated solely to a specific process, subtract the SHR value from the RES value. High SHR values generally indicate efficient memory usage through shared resources, whereas high RES values with low SHR suggest the process is consuming significant dedicated RAM.