Limiting process memory consumption with rsetlimit and limit. . .

Chuck Swiger cswiger at mac.com
Mon Apr 18 13:29:25 PDT 2005


David Grochowski wrote:
> I'm currently working on a project where I need to limit the amount of
> physical memory a process uses.  I've tried the rsetlimit function and the
> limit shell command to do so, but I have had no luck (though I was able to
> limit the virtual memory and cause it to segfault).  Neither seems to have
> any effect on the physical memory available to the process.  If anyone
> could enlighten me on how to limit the physical memory available to a
> process, it would be greatly appreciated.

setrlimit(RLIMIT_RSS, ...) in C or something like:

8-sec# limit memoryuse 10
9-sec# limit
cputime         unlimited
filesize        unlimited
datasize        500MB
stacksize       64MB
coredumpsize    100MB
memoryuse       10MB
memorylocked    unlimited
maxproc         256
descriptors     512
sockbufsize     unlimited
vmemorysize     unlimited

This is zsh, other shells may have slightly different syntax.
In /bin/sh: "ulimit -Sm 10240"?

-- 
-Chuck



More information about the freebsd-questions mailing list