← Back to context

Comment by adrian_b

21 hours ago

I stopped using swap almost a quarter of century ago, and since then I have not seen a PC with Linux freezing because of full RAM.

Before the recent increase in RAM prices, it was not difficult to have a generous amount of RAM in a PC, that would make very unlikely the out-of-memory situations.

When OOM really happened, it was much better to become aware of this immediately, and reduce the number of concurrent threads for a running job, or whatever caused that, instead of having reduced performance or even freezing.

It depends on the memory conditions you end up in an OOM with. In some cases Linux starts to just trash swap and never kills anything because it thinks it can free a few pages at a sufficient tempo. This is where turning off swap helps by just forcing the OOM killer to act sooner. On other devices it can make things worse. In the end it's still all terribly handled by Linux.

Mannnnn.... I've done similar and have NOT had the same experience. The problems I've had are usually because I'm loading stuff in a weird disk-memory-cpu trifecta and they all really want to push the remaining 30GB stuff into a database. Then it's off to ctrl-alt-f5 to wait for gnome to crash so I can auth in and kill the ravaging process.

My PC doesn't have swap and it freezes for about 20 s when I run out of memory until the OOM killer finishes its job, usually by killing Code or more rarely Firefox. I'll take this over the machine swapping so slowly that I need to hard reset anyway, but I'd appreciate it if the OS could stay more responsive when it happens.

Unfortunately Linux makes it difficult to fully get away from swapping because any file-backed page is eligible to be evicted, and even if you have "disabled swap" the kernel will cheerfully page-out your program, even if it needs to be immediately paged in again to continue. The only way to stop it from doing so is to remap all executable mappings into anonymous memory, a thing which is possible but which the loader and linker do not make easy.

  • This type of thrashing was the most common OOM issue I saw on my servers, the system would effectively deadlock until I pulled the plug. In my setup this seemed to be caused by slow-ish disks, and using a small amount of zram made things more CPU-bound / less IO-bound. I haven’t seen the problem since, the OOM killer does what I expect.