Is the memory which is transferred to swap due to swappiness still cached in the physical memory (until it is invalidated there)?
1 Answers
Yes, the kernel will know the pages are available in both places so it can reallocate the RAM if it needs to (knowing the pages are already copied to disk). If the pages are read back into RAM later they remain on disk too (unless swap space is congested and it need to be used to page out something else).
The amount of data in pages available in both RAM and in swap at any given time can be found in /proc/meminfo
under the SwapCached
heading.
The kernel is unlikely to write something to swap unless it is about to immediately reallocate the RAM they occupy though. A high swappiness values doesn't mean it will swap things out needlessly - it just means it will be more likely to swap pages out to make room for buffers/cache/similar when needed instead of clearing older blocks from cache.
- 22,534
- 42
- 66
-
+1, One minor edit, most modern kernels will also swap when memory has been idle for a long time, even if it doesn't need the space. – Chris S Jul 02 '10 at 12:36