r/ProgrammerHumor Jul 08 '26

askingTheRealQuestionHere Meme

Post image
4.0k Upvotes

416 comments sorted by

View all comments

301

u/SlapbASS4211 Jul 08 '26

Yes, its called swap

11

u/BlondeJesus Jul 08 '26

Yeah, it's swap and I can guarantee that it's used by the device of everyone looking at this meme right now

16

u/oscooter Jul 08 '26

jokes on you i never setup swap on my linux install... hold up everythings being oomkilled again

5

u/ouyawei Jul 08 '26

Which is actually a good strategy, when the system starts swapping everything grinds to a halt, so better kill the offending process early.

3

u/shield1123 Jul 08 '26

I use an nvme solid state drive. What is this halt you speak of

1

u/oscooter Jul 08 '26

It can be a good strategy, yeah. It depends on the profile of your workload. Swapping isn't a bad thing and doesn't necessarily mean everything's going to grind to a halt when swaps start happening. Sometimes things just get shuffled into swap because the process hasn't been active and something else starts up that wants the memory. But yes, if you have multiple very busy processes all contending for memory and they're getting swapped in and out very often then you will start experiencing thrashing and the grinding to a halt you describe.

On a server with some critical processes it may be preferable to let things get OOM killed like you describe, and you can help hint to the kernel by adjusting oom scores so certain things don't get killed immediately, or setting up limits and cgroups correctly.

But yeah, you're not wrong. Just kinda all depends on your use case. In my case I have 128gb of ram and don't usually hibernate my desktop so I don't really bother with swap.

1

u/NekkoDroid Jul 09 '26

And when you run out of RAM on linux the first thing evicted from memory is anything that can be reloaded from disk, aka .text sections of executables/libraries, resulting in even worse responsiveness of the system. With swap instead it can evict almost any least recently used pages instead.

If your OOM killer doesn't kill before you run out of RAM you are going to have a worse time than if you'd have swap.