Re: strange VM and swap behavior ?

Stephen C. Tweedie (sct@redhat.com)
Mon, 30 Aug 1999 11:56:58 +0100 (BST)


Hi,

On 29 Aug 1999 15:16:59 +0200, Marc Lefranc <Marc.Lefranc@nordnet.fr>
said:

> Summary: I observe strange behavior related to virtual memory and
> swap. When playing an animated gif with xanim, virtual memory can
> eventually be exhausted although the total of physical memory + swap
> is well above what should be needed. Also, the amount of "cached"
> memory is strangely high for a situation of heavy swapping, and there
> seems to be some duplication between swap and the cached pages.

"cached" includes the "swap cache", a mechanism which is used when we
get a read memory access to a page of swapped memory. When that
happens, we pull in the page from disk but we don't remove that copy on
disk --- the copy in memory becomes effectively a local cache of the
disk copy, and counts as cached memory. If we want to discard that copy
from memory in the future, we can do so without writing it back to disk
because we know that the in-memory copy has not been modified since we
first read it from disk.

> This is not a memory leak, because when the cached pages are later
> thrown, associated swap space is then freed, but this behavior
> actually requires much more swap than would be strictly needed.

No, the swap cache is using both on-disk swap and in-core memory for the
same data, just as the page cache contains an in-core memory copy of
regular files on disk. That is quite deliberate.

--Stephen

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/