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:
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?