My conclusion is: In production, in a datacenter, when code is stable and compute-per-dollar efficiency matters? Yeah, sure, I can believe that swap makes sense.
On a dev machine? Not on mine for sure. If you think swap is a net positive on a dev machine, then try pasting the following (wrong) code in a bash prompt on Linux:
echo '
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
for (int i = 0; ; i++) {
char *mem = malloc(1 << 30);
if (mem == NULL)
return 0;
memset(mem, 42, 1 << 30);
printf("%5d GiB\n", i);
}
}
' | cc -O3 -o crash_my_laptop -x c -
./crash_my_laptop
We can discuss the results in a couple of hours, when you recover control of your machine.
(Note: with no swap and no z-ram, it crashes after 10 seconds; no side effects.)[1]
https://news.ycombinator.com/item?id=40582029
https://news.ycombinator.com/item?id=39650114
https://news.ycombinator.com/item?id=38263901
https://news.ycombinator.com/item?id=31104126
https://news.ycombinator.com/item?id=29159755
https://news.ycombinator.com/item?id=23455051