I have the following situation – I’ve got a remote PC with an encrypted drive. If the PC needs a restart, I need to be physically present to enter the decryption password because I don’t have any way of ssh-ing to it before the OS is loaded.
With this in mind, I use the PC to run my jupyter notebook. Only problem is, sometimes, I end up executing a piece of code which quickly consumes all available memory – 32G and then machine becomes unresponsive and that’s it for my access to it.
I remember at uni, writing a C program which in a loop launched itself within itself – basically a RAM hog. The program got killed by a watchdog daemon before eating up all available memory and crashing the PC. What can I do to achieve this? Play around with ulimit? This seems too simple.
Thanks to Artem’s suggestion, I found this about the solution he has proposed. Seems earlyoom will do the trick.
https://www.reddit.com/r/linux/comments/d2nssy/a_userspace_outofmemory_killer_oomd_020_released/
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
My personal favorite is earlyoom (included and enabled by default in Fedora 32): https://github.com/rfjakob/earlyoom
Otherwise you can choose from:
- Nohang: https://github.com/hakavlad/nohang
- oomd: https://github.com/facebookincubator/oomd
- low-memory-monitor: https://gitlab.freedesktop.org/hadess/low-memory-monitor/
- psi-monitor: https://github.com/endlessm/eos-boot-helper/tree/master/psi-monitor
Edit 2021-12-21:
- Modern distros with systemd now include a built-in OOM killer called
systemd-oomd, checkman systemd-oomdfor more details.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0