views:

146

answers:

1

Isn't the point of caching things in main memory to avoid the expensive disk i/o?

If you're caching things in the swap space of a hard drive, how does that avoid disk i/o?

+2  A: 

Generally the memory used by the cache wouldn't get swapped out. It would be marked as in-use.

edit - Yes virtual memory is memory blocks copied to disk because the RAM is full. In order to use it you have to copy it back into memory (which is slow).
Cache is keeping copies of recently used files in memory because this is quicker than going back to disk for them. There is a conflict here - the more RAM you use for cache, the more other memory you have to swap out to disk.
This isn't necessarily bad, there are lots of things running on your computer that only run occaisonally and so pushing them out to disk to make space for cached copies of your photos might make sense.

Martin Beckett
ah, so the swap space is just to support virtual memory, and not so much to improve performance, correct?
Yes. (obligatory minimum comment length text here)
cfeduke
It can improve performance by freeing memory to be used by caches.
CesarB