Clean pages are pages that have not been modified since they were mapped (typically, text sections from shared libraries are only read from disk (when necessary), never modified, so they'll be in shared, clean pages).
Dirty pages are pages that are not clean (i.e. have been modified).
Private pages are available only to that process, shared pages are mapped by other processes*.
RSS is the total number of pages, shared or not, currently mapped into the process. So Shared_Clean
+ Shared_Dirty
would be the shared part of the RSS (i.e. the part of RSS that is also mapped into other processes), and Private_Clean
+ Private_Dirty
the private part of RSS (i.e. only mapped in this process).
PSS (proportional share size) is as you describe. Private pages are summed up as is, and each shared mapping's size is divided by the number of processes that share it.
So if a process had 100k private pages, 500k pages shared with one other process, and 500k shared with four other processes, the PSS would be:
100k + (500k / 2) + (500k / 5) = 450k
Further readings:
Regarding process-wide sums:
*Note that a "share-able" page is counted as a private mapping until it is actually shared. i.e. if there is only one process currently using libfoo
, that library's text section will appear in the process's private mappings. It will be accounted in the shared mappings (and removed from the private ones) only if/when another process starts using that library.
+The values don't add up exactly for all processes. Not exactly sure why... sorry.
There is no command that gives the “actual memory usage of a process” because there is no such thing as the actual memory usage of a process.
Each memory page of a process could be (among other distinctions):
- Transient storage used by that process alone.
- Shared with other processes using a variety of mechanisms.
- Backed up by a disk file.
- In physical memory or swap.
I think the “dirty” figure adds up everything that is in RAM (not swap) and not backed by a file. This includes both shared and non-shared memory (though in most cases other than forking servers, shared memory consists of memory-mapped files only).
The information displayed by pmap
comes from /proc/PID/maps
and /proc/PID/smaps
. That is the real memory usage of the process — it can't be summarized by a single number.
Best Answer
It sounds like you really need some type of continuous monitoring tool to record statistics like memory usage over time.
I would suggest what you are doing now and repeatedly running the ps command to get size of memory used per process.
You would need a way to parse the output into a human-readable chart or table to show values over time.
Personally, I like this little command I had taken from someone on another forum to show memory usage in a human-readable way: