I had a very unfortunate situation, where a bash script that contained a subtle error gone wild and took all available memory and then started killing other tasks (production apps!) to get even more.
How can I future-proof invocations of this and other scripts so when they reached memory limit they fall themselves and not kill other apps?
I'd prefer something I could incorporate into the text of the script.