4 ms·
> The only concrete answer to "why have swap if I have enough RAM" is "well, if you run out of RAM..." Linux with swap available can swap out never used pages
by xani_ 4y ago
> The only concrete answer to "why have swap if I have enough RAM" is "well, if you run out of RAM..."
Linux with swap available can swap out never used pages (say a part of library that never gets called) and use freed memory to cache disk IO. We see that on every server that has enough data to fill the remaining RAM with page cache. But you only need like a gig of swap to take advantage of it.
- AnotherGoodName 4y agoYep the lesson a lot of people who claim 'no swap is better' need to learn is that your OS is always swapping, even without a swap file. The lack of swapfile just removes some flexibility in how that's handled. The OS will page in files that are being accessed regularly. Without a swap file you don't stop the OS swapping between memory and disk, that'd be pathological since disk access is that much slower. Instead what not having a swapfile really means is that you are telling the OS "anything allocated ever on the system is more important than disk cache".