0

I routinely perform numerical computations in my laptop, using programs that I write myself in Python, Julia, C++, etc. I am not a perfect programmer (far from it), and I make coding errors frequently. Sometimes, I end up with a program that drains memory. Usually when this happens, my system becomes completely unresponsive, and I am forced to do a hard reboot (Ctrl + Alt + F1 does not work, sometimes not even the OOM killer, which I don't like because I can't be sure about what it will kill). See for example these relevant discussion:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/159356, https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1504914

Given these risks, I would like to run my program in a shielded way, constraining the memory it will use. Is there a tool in Linux to execute a command with bounded memory?

a06e
  • 1,727
  • 3
    Check the manual page for ulimit. – DopeGhoti Sep 29 '17 at 19:57
  • You could run it in a virtual machine on your laptop. Adds overhead, but would limit the process(es) to whatever resources you allocate the VM. – cherdt Sep 29 '17 at 20:09
  • @cherdt that's not an option for me. I need the program to run as fast as possible. Memory bounding should imply little overhead. – a06e Sep 29 '17 at 20:25
  • There's another question/answer on unix.stackexchange which talks about this. See https://unix.stackexchange.com/questions/44985/limit-memory-usage-for-a-single-linux-process. – Johnathan J. Sep 29 '17 at 20:43

0 Answers0