12

Back in the day I used to curse the OOM-killer for being over-aggressive and killing apps I was using. Now, as I periodically watch my system thrash for 15 minutes because of some ill-behaved program, and then finally resort to a force-power-off because it won't respond to the keyboard, I realize I had it better than I realized back then.

How do I restore the OOM-killer to its old, bloodthirsty ways?

  • 1
    Take a look at the programs causing an issue, and limit the amount of memory they can suck up with limits.conf – LawrenceC May 7 '13 at 1:44
4

I would decrease the amount of swap space you have available. Typical installs these days attempt to allocate as much swap as there is physical memory (or sometimes twice as much). The problem with this is that when something goes awry, the system goes into a death-spiral of attempting to "shuffle" things from memory to disk, and back, and it starts doing so much of that it doesn't have time to respond to user input.

In the good-ol-days, entire processes were swapped out to disk (and back), hence large swaps were needed.

In modern virtual memory systems, memory is swapped out in blocks (rather than whole processes), so you can get by with smaller swaps. In your scenario, you'd be better off having processes killed, so running with smaller swap will cause OOM to start killing processes sooner (rather than having the system spend inordinate amounts of time swapping stuff to/from disk).

  • I have zero swap, and my system locks up for 20+ minutes when I have an infinite javascript loop in chromium than pushes onto an array or something. I need to OOMK to trigger before my system is useless, not way way after. – JasonWoof Aug 7 '18 at 15:20
0

Here's what worked for me:

echo 1 > /proc/sys/vm/oom_kill_allocating_task

That's for just this boot. You can test by running the following in the console tab of your browser's inspector:

a = []; while (true) { a.push(1); }

If you're happy with this setting, you can make in the default for all future boots:

echo "vm.oom_kill_allocating_task=1" >> /etc/sysctl.conf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.