Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Private_Dirty" memory mean in smaps?

I have a huge RAM-consuming Java process and I'm trying to figure what he's doing with all this memory. So, I'm doing a pmap -x on this PID and here is a piece of the result :

Address           Kbytes     RSS   Dirty Mode   Mapping
0000000000001000       4       0       0 rw---    [ anon ]
0000000000400000      48       0       0 r-x--  java
000000000050b000       4       4       4 rw---  java
0000000003b9d000     264     224     212 rw---    [ anon ]
0000000003bdf000 2199556 1887992 1830160 rw---    [ anon ]
000000396c800000     112     108       0 r-x--  ld-2.5.so
000000396ca1c000       4       4       4 r----  ld-2.5.so
[...]
ffffffffff600000    8192       0       0 -----    [ anon ]
----------------  ------  ------  ------
total kB         7072968 4382820 4270104

As you can see on address 3BDF000 there is a mapping of 2199556 KBytes with 1830160 of Dirty.

In /proc/10139/smaps, on can see it with more details :

03bdf000-89fe0000 rw-p 03bdf000 00:00 0
Size:           2199556 kB
Rss:            1887996 kB
Shared_Clean:         0 kB
Shared_Dirty:         0 kB
Private_Clean:    57832 kB
Private_Dirty:  1830164 kB
Swap:            231996 kB
Pss:            1887996 kB

Hence, I'd like to know what this dirty memory is? I guess these pages don't have to be written to disk, so why are they called dirty?

like image 432
Poulpatine Avatar asked Jul 11 '13 13:07

Poulpatine


People also ask

What is private clean memory?

Private_Clean. Private_Dirty. 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).

What is Proc PID Smaps?

The /proc/PID/smaps is an extension based on maps, showing the memory consumption for each of the process's mappings.


1 Answers

Memory is either private, meaning it is exclusive to this process, or shared, meaning multiple processes may have it mapped and in use (think shared library code, etc.). Memory can also be clean - it hasn't been modified since it was loaded from disk or provided as zero-filled pages or whatever, and so if it needs to be freed to provide memory pages for other processes, it can just be discarded, and reloaded/re-filled if it is ever needed again - or dirty, which means if it needs to be freed up, it must be written out to a swap area so that the modified contents can be recovered when necessary.

It's not necessarily unusual to see large amounts of private dirty data in a process. The problem is when the sum of all private dirty data across all processes in the system becomes a significant portion (exact numbers depend greatly on your workload and acceptable performance) of your overall physical memory, and stuff has to start being swapped in/out...

like image 193
twalberg Avatar answered Sep 29 '22 01:09

twalberg