The first thing that VM does is clean pages and move them to a clean list.
When clearing anonymous memory (things that do not have actual file backup storage, you can see segments in / proc // cards that are anonymous and do not have the vnode storage file system behind them), the first thing VM will do is take the dirty pages and "clear" and then write the contents of the page for sharing. Now that the virtual machine is running out of free memory and worried about its ability to provide new free pages that can be used, it can go through the list of "clean" pages and be based on how recently they were used and what memory they will be moving these pages are in a free list.
Once memory pages are put on a free list, they are no longer associated with the content they had before. If the program indicates the location of the memory on which the page used to be, the program will have a serious error, and the page will be grabbed from the free list (most likely, completely different), and the data will be read from the disk on the page. Once this is done, the page actually remains โcleanโ because it has not been modified. If the VM decides to use this page as a swap for another page in RAM, then the page will be "dirty" again, or if the application writes to this page, it will be "dirty". And then the process begins again.
In addition, swappinness is quite terrible for server applications in a business / transaction / online / latency environment. When I have 16 GB RAM boxes where I donโt run many browsers and graphical interfaces, I usually want all my applications to be almost locked in memory. The bulk of my memory is usually 8-10 GB java heaps, which I NEVER want to unload to disk, ever, and the available crates are processes like mingetty (but even there glibc pages are used in these applications it is actually used by other applications, so even the RSS size of these useless processes is mainly used by shared pages). Usually I don't see more than a few 10 MB of 16 GB actually cleared of sharing. I would recommend very, very low numbers of swappiness or zero swappiness for servers - unused pages should make up a small part of the total RAM and try to restore this relatively small amount of RAM for the risks of cache cache, swapping application pages and accepting latent calls to a running application.
Lamont
source share