I'm implementing an algorithm that needs to run under a hard memory limit of 4MB.
Is there a way to run a process in a way that it would get killed if it over-reaches its memory limit? Or simply just profile its allocations to be able to see how much maximum memory has been allocated?
I think ulimit is what you're looking for: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man3/ulimit.3.html
Ulimit don't work all the time though, and alternative ways of limiting a process system resources is mentioned here: How to limit memory of a OS X program? ulimit -v neither -m are working
Also the same question has been asked here, so this question might bring some enlightenment on the problem, especially concerning virtual memory: https://apple.stackexchange.com/questions/43371/way-to-limit-how-much-ram-an-arbitrary-process-can-take-up
You will probably get a hard limit by following this tip thou, together with the use of ulimit: http://hints.macworld.com/article.php?story=201106020948369
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With