0

This question already has an answer here:

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?

marked as duplicate by 200_success, Stephen Rauch, roaima, Jeff Schaller, G-Man Sep 30 '17 at 1:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 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. – becko Sep 29 '17 at 20:25
  • There's another question/answer on unix.stackexchange which talks about this. See unix.stackexchange.com/questions/44985/…. – Johnathan J. Sep 29 '17 at 20:43

Browse other questions tagged or ask your own question.