3 ms·
Swap is the only mechanism through which a non-mmapped page in memory can be swapped out, therefore if running without swap and there exists any ram which is ac
by PhilipRoman 3y ago
Swap is the only mechanism through which a non-mmapped page in memory can be swapped out, therefore if running without swap and there exists any ram which is accessed less commonly than the next-most-commonly-accessed area of disk currently not in cache, the memory utilization is suboptimal.
I've seen a lot of tools getting this wrong, even earlyoom which, AFAIK only measures memory and swap usage, but not the sustained rate of swapping. My computer can run just fine with all of it's swap used while ram is half empty.
Any implementation of overcommit is inherently unstable and susceptible to a "bank-run" situation, adding or removing swap will not change that. If you want a robust system, preallocate memory for everything and set limits via cgroups.
- shrimp_emoji 3y agoThese are the esoteric and technical arguments that scare me into still using a swapfile and which maybe answer why I see my swap space being used when I have like 60 GB of RAM free (neither of which make any sense otherwise). :p
- juujian 3y agoSame boat. But hey, last year I had to get a 30GB dataset into memory so you never know... Though now I'm smart enough to optimize better.
- radicalbyte 3y agoOh you're a Chrome user too? :-)
- colanderman 3y agoSimpler answer is: at one point stuff got put into swap to make room for a memory-hungry task, and it hasn't been referenced since, so no need to pull it back into RAM.
- bsdetector 3y ago> if running without swap and there exists any ram which is accessed less commonly than the next-most-commonly-accessed area of disk currently not in cache, the memory utilization is suboptimal. Memory that is swapped out is a small write operation, which generally is much more resource and wear intensive than a read; a program memory page and disk cache page are not equivalent. Additionally, the swapped out program memory may be required again and cause an unpredictable delay in program operation; when a user has to wait for a menu to open while it is swapped back in that is suboptimal use of memory. A modern operating system should have compressed memory rather than swap. Take the pages that would be swapped out for being rarely accessed, if they compress well then free the page and store it in an area for compressed pages. This will get most of the expanded cache benefit from swap without delays, wear, or possibility of the system grinding to a halt.