How can I kill a process when ram reaches 100% and renders the system unresponsive?

Hi,

My system will frequently spike randomly to 100% ram use and freeze. I believe this is an issue with Genymotion rather than EndeavourOS, but troubleshooting Genymotion is beyond my scope, so I’m wondering if there’s a method to kill processes when the freeze occurs? At the moment nothing is responsive and it forces me to cut the power, which I’d rather like to avoid.

If your whole system is frozen, you can’t. If it is only your DE that is frozen you could try ssh’ing in if you have sshd enabled. You can also try switching to a TTY but if your DE is frozen that probably won’t work.

A long-term solution is to run an out of memory killer like systemd-oomd which prevents that situation from occurring.

1 Like

Systemd-oomd seem like the solution then. Is there documentation on how to set this up somewhere?

Fedora has it enabled by default. This might serve as an starter for further research:

https://fedoraproject.org/wiki/Changes/EnableSystemdOomd

1 Like

there are several ways to limit the memory a process is allowed, which seems like a more graceful thing than killing it when it takes more than you can spare

Found this:

You can install and enable it:

  sudo pacman -S earlyoom
  sudo systemctl enable --now earlyoom

Note that I haven’t used this so I don’t know anything more about it.

1 Like

This might not help, and I am guessing, but you could try a program called “ananicy” to set priorities to where it can’t use 100%. If you are using pamac and enable the aur repo’s you can install it from there.
Not sure if that is what you are looking for or not, it’s another nice-daemon, but maybe it can keep the program in question from taking over your system.

Anyway, I’m no expert, and I’m a noob on the forums so take my opinion as a grain of salt.

I hope you get it worked out. Not sure if I can help but I thought I would try. Good luck!

If your computer freezes for running out of RAM, do not reset it by using the power or reset buttons on the case (or, even more savagely, unplugging it). You risk filesystem corruption and there is almost never a practical need to do so on Linux.

Even if your computer is utterly unresponsive due to an OOM event, you can still use the Magic SysRq button + REISUB to kill all procesess and reboot, which is a perfectly safe thing to do (except, of course, you’ll lose any unsaved data in the RAM, which is unavoidable).

I prefer this way of rebooting the system when I run out of RAM to any OOM killers, simply because it happens so exceptionally rarely. In fact, it never happened to me that I ran out of RAM to the point my computer froze, except when I intentionally did it to see what happens when I run out of RAM.

Constantly running a daemon just in case of such a rare event (which can be recovered from by safely rebooting the computer) seems wasteful of resources to me. But that is just a personal preference, of course.

5 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.