1

Is the memory which is transferred to swap due to swappiness still cached in the physical memory (until it is invalidated there)?

1

1 Answer 1

4

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.

1
  • +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 2, 2010 at 12:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .