3 ms·
I still don't get how that answers the question. If I have enough RAM for both the "hardly ever used" pages and the "more frequently used" pages then what good
by mason55 7y ago
I still don't get how that answers the question. If I have enough RAM for both the "hardly ever used" pages and the "more frequently used" pages then what good is the swap doing me?
The only way that makes sense is if there is some cache the kernel has which is faster than RAM. BUT the kernel cannot move things between this cache and RAM, it can only treat the cache + RAM as a single blob, so to free up space in the cache the kernel has to move pages to disk. So by having some swap space the kernel can move hardly ever used pages to disk which is the only way to free up space in this cache.
It's possible that what I just described really exists, I don't know that much about the internals of how the kernel manages memory. But if that is what's happening then THAT is the detail that would have been useful in this post.
- wrycoder 7y agoIt does work that way. I had a small, very lightly loaded VPS that had no swap. Occasionally, it would not start all its services on boot, in particular the db, due to OOM. Adding a small amount of swap allowed it to boot cleanly. The swap was not subsequently used. The alternative was to upgrade the server RAM at double the monthly cost.