In defense of swap: common misconceptions (2018)
(The article is from 2018.)I think the article is strongly from the point of view of what to do "in production". If you have a bunch of servers with known specialized workloads, I can believe that enabling swap is good for efficiency. You can run more tasks and get closer to the memory limit while remaining safe. Coming from a Facebook employee, this makes sense.However, for individual development machines, the pragmatic situation is completely different. The truth is that in practice running out of memory stems from two types of human errors:1. You wrote some code that leaks lots of memory quickly.2. You used Google Chrome.In either situation, still in 2022, Linux reacts in the following way:A. With swap, your system becomes completely unresponsive for longer than you have patience for, so you power-cycle it.B. Without swap, the culprit is immediately identified and killed. Your system is perfectly usable, aside from a killed process.Note that depending on your distro, the good case B. may have become a bit harder to achieve recently: systemd-oomd now tries to eagerly detect OOM situations before the kernel, and when it does, it kills the offending process' whole cgroup! If you have gnome or kde, you're good, but otherwise, this may terminate your session. This can be fixed with "systemctl mask systemd-oomd.service"