Earlier this week on the Linux kernel mailing list, Artem S. Tashkinov described a low-memory scenario where “the system will stall hard. You will barely be able to move the mouse pointer. Your disk LED will be flashing incessantly…”
“I’m afraid I have bad news for the people snickering at Linux here,” wrote Chris Siebenmann, a sys-admin at the University of Toronto’s CS lab. “If you’re running without swap space, you can probably get any Unix to behave this way under memory pressure…”
In the old days, this usually was not very much of an issue because system RAM was generally large compared to the size of programs and thus the amount of file-backed pages that were likely to be in memory. That’s no longer the case today; modern large programs such as Firefox and its shared libraries can have significant amounts of file-backed code and data pages (in addition to their often large use of dynamically allocated memory, ie anonymous pages).
A production engineer (now on Facebook’s Web Foundation team) wrote about experiencing similar issues years ago when another company had disabled swapping when they replaced or reinstalled machines — leading to lots of pages from hosts that had to be dealt with. This week they wrote:
I stand by my original position: have some swap. Not a lot. Just a little. Linux boxes just plain act weirdly without it. This is not permission to beat your machine silly in terms of memory allocation, either… If you allocate all of the RAM on the machine, you have screwed the kernel out of buffer cache it sorely needs. Back off.
Put another way, disk I/O that isn’t brutally slow costs memory. Network I/O costs memory. All kinds of stuff costs memory. It’s not JUST the RSS of your process. Other stuff you do needs space to operate. If you try to fill a 2 GB box with 2 GB of data, something’s going to have a bad day! You have to leave room for the actual system to run or it’s going to grind to a stop.