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/