3

Is it possible to limit the amount of memory a process consumes from the command line and eventually automatically kill the process if it tries to overpass this limit?

Something like

MaxRam -4GB ./MyProcess args

For your information, I am on Mac OSX Version 10.11.3.

2
  • 1
    On Linux there is a ulimit command which allows control over the resources "on systems that allow such control" (help ulimit or man bash for information), but I don't know if the limit extends to any or all subprocesses launched; if not OSX may have system programs to specify the limits on a program as it is run, but this would not be a bash internal command.
    – AFH
    Commented Apr 6, 2016 at 22:05
  • more answers/comments can be found here -- it seems like there is no way to do this (please feel free to correct me!) Commented Feb 17, 2018 at 23:43

1 Answer 1

0

On Linux you'd use:

prlimit -m4000000000 ./MyProcess args

Note that -m limits the RSS, use -v to limit virtual memory.

https://www.unix.com/man-page/osx/1/prlimit/ ← This seems to suggest that the command is also available on macOS, although I haven't tried.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .