Live data from Hacker News

There is an OOM kill count in Linux

medium.com

11–20 of 66 posts

Re: There is an OOM kill count in Linux

#12

Out of curiosity, what do people recommend for OOM these days on Linux? My number one recurring issue on Ubuntu is me not noticing the memory usage, running out of memory and locking up my system (forcing a hard reboot and loss of unsaved work) EDIT: I'd preferably like an OOM handler that would freeze my system and pop up a little menu from which I could select which process to nuke

systemd-oomd [0].

You can also use facebook's oomd, but the systemd one is basically the same and slightly better.

If you want, you can also write your own custom memory pressure handler using the recent PSI features: https://docs.kernel.org/accounting/psi.html

The other, easier, answer is to buy more ram, if you simply have more memory than you will ever use (such as having 128GiB of memory when you only regularly use 30GiB), you'll rarely run into OOM issues.

[0]: https://www.freedesktop.org/software/systemd/man/latest/syst...

Re: There is an OOM kill count in Linux

#13

Out of curiosity, what do people recommend for OOM these days on Linux? My number one recurring issue on Ubuntu is me not noticing the memory usage, running out of memory and locking up my system (forcing a hard reboot and loss of unsaved work) EDIT: I'd preferably like an OOM handler that would freeze my system and pop up a little menu from which I could select which process to nuke

For desktop use, nohang does what the name says.

https://github.com/hakavlad/nohang

Re: There is an OOM kill count in Linux

#14
post #10

Earlier quoted context omitted.

I've never had that problem. Maybe you don't setup much swap space as I would expect the system to run well enough to save your work and shutdown for most common leaks.

Swap usually makes it worse, without swap there is some chance that the Linux OOM killer does something useful and saves the system. With swap, it becomes a frozen system that never manages to kill anything due to all the swapping. You can wait 5 minutes, 10 minutes, or 15 minutes, but the system never recovers without a reboot.

That would normally mean you ignore the system getting slower for a long time.

Re: There is an OOM kill count in Linux

#15
post #10

Earlier quoted context omitted.

Swap usually makes it worse, without swap there is some chance that the Linux OOM killer does something useful and saves the system. With swap, it becomes a frozen system that never manages to kill anything due to all the swapping. You can wait 5 minutes, 10 minutes, or 15 minutes, but the system never recovers without a reboot.

That would normally mean you ignore the system getting slower for a long time.

Not a long time. With swap enabled, when a process consumes too much memory your system goes from perfect performance to cursor lagging to everything is frozen and you can't even switch to a TTY within 5-10 seconds.

Without swap, the system lags for a couple seconds, OOM killer frees up memory and you're good to go again. The only slowdown is any pages that were kicked out from the file cache. But those quickly come back after the OOM killer does its thing.

Re: There is an OOM kill count in Linux

#16

Out of curiosity, what do people recommend for OOM these days on Linux? My number one recurring issue on Ubuntu is me not noticing the memory usage, running out of memory and locking up my system (forcing a hard reboot and loss of unsaved work) EDIT: I'd preferably like an OOM handler that would freeze my system and pop up a little menu from which I could select which process to nuke

This is one area where Windows is far superior to Linux as a desktop experience.

By accident, I once wrote an infinite loop that just allocated a bunch of memory. As I ran the program my Windows system quickly became laggy and unresponsive. However, not completely. With a bit of patience I got Task Manager up and managed to kill the process and the system was back to normal within a minute.

On Linux, I experience the same as you. Everything is fine until suddenly it's completely unresponsive. Most of the time I can't even manage to shut down the system cleanly and have to hard reset.

Re: There is an OOM kill count in Linux

#17

Out of curiosity, what do people recommend for OOM these days on Linux? My number one recurring issue on Ubuntu is me not noticing the memory usage, running out of memory and locking up my system (forcing a hard reboot and loss of unsaved work) EDIT: I'd preferably like an OOM handler that would freeze my system and pop up a little menu from which I could select which process to nuke

Buying more RAM?

Re: There is an OOM kill count in Linux

#19
post #15

Earlier quoted context omitted.

That would normally mean you ignore the system getting slower for a long time.

Not a long time. With swap enabled, when a process consumes too much memory your system goes from perfect performance to cursor lagging to everything is frozen and you can't even switch to a TTY within 5-10 seconds. Without swap, the system lags for a couple seconds, OOM killer frees up memory and you're good to go again. The only slowdown is any pages that were kicked out from the file cache. But those quickly come…

What if the thing you kill is in the critical stack to saving your work? If it isn't I don't really understand why you would be swapping it in a lot

I would view the OOm solution as a compute as cattle thinb, but here we are talking about a user desktop where the user can take the best action for themselves once they realize there's a problem.

Re: There is an OOM kill count in Linux

#20
post #15

Earlier quoted context omitted.

Not a long time. With swap enabled, when a process consumes too much memory your system goes from perfect performance to cursor lagging to everything is frozen and you can't even switch to a TTY within 5-10 seconds. Without swap, the system lags for a couple seconds, OOM killer frees up memory and you're good to go again. The only slowdown is any pages that were kicked out from the file cache. But those quickly come…

What if the thing you kill is in the critical stack to saving your work? If it isn't I don't really understand why you would be swapping it in a lot I would view the OOm solution as a compute as cattle thinb, but here we are talking about a user desktop where the user can take the best action for themselves once they realize there's a problem.

> If it isn't I don't really understand why you would be swapping it in a lot.

The user doesn't decide which processes are swapped in. If the process gets CPU time and tries to access its data, that data will get swapped in.

> We are talking about a user desktop where the user can take the best action for themselves once they realize there's a problem.

You can't do that with swap, because once you realize there's a problem, you cannot even move your cursor or run commands to take any actions.

Post reply on HN