If you have ever tried to figure out why Linux is running low on memory, you will agree that the memory usage information provided by the kernel is not exactly easy to understand.
This post will attempt to provide a quick explanation of what Pss means in the /proc/PID/smaps file.
/proc/PID/smaps is an extension based on maps. It shows the memory consumption for each of a process’ mappings. For each mapping, there are a series of lines (see the block below for a sample portion of the smaps file of a random process – I grabbed that from one of my Linux boxes).
PSS stands for Proportional Set Size.
The Pss of a process is a count of the number of pages the process has in memory. But this isn’t a straightforward count. Each page is divided by the number of processes sharing it. So if our process has 1000 pages by itself alone, and another 1000 shared with one other process, the Pss of our process will be 1500.
Here’s how a portion of a typical smaps file may look like. Notice the variables:
562baaa22000-562baae25000 r-xp 00000000 fc:01 2692 /usr/bin/php-cgi7.2 Size: 4108 kB KernelPageSize: 4 kB MMUPageSize: 4 kB Rss: 3740 kB Pss: 225 kB Shared_Clean: 3740 kB Shared_Dirty: 0 kB Private_Clean: 0 kB Private_Dirty: 0 kB Referenced: 3740 kB Anonymous: 0 kB LazyFree: 0 kB AnonHugePages: 0 kB ShmemPmdMapped: 0 kB Shared_Hugetlb: 0 kB Private_Hugetlb: 0 kB Swap: 0 kB SwapPss: 0 kB Locked: 0 kB VmFlags: rd ex mr mw me dw sd
In this case, Pss = 225 kB.
The first line above shows the same information for the mapping as is contained in the /proc/PID/maps file.
The other lines provide a number of extra details including:
- The mapping size (Size)
- The proportional share of this mapping that belongs to the process (Pss)
- The amount of the mapping that currently sits in RAM (Rss)
- The amount of memory currently marked as referenced or accessed (Referenced)
- How many dirty and clean private pages are in the mapping (Private_Dirty and Private_Clean respectively). Note: Even if a page is part of the MAP_SHARED mapping, if it has only one pte mapped, is counted as private (not as shared).
- The amount of memory that does not belong to any file (Anonymous)
- The amount of would-be-anonymous memory that is used but stored on swap (Swap)
This post is primarily for reference purposes. My explanation is based on some of the information provided at the Linux Kernel Documentation.