Memory limits

Hi, all. Is there any way to limit process memory based on top's RES column? virtualmem (limits -v) seems to limit on the SIZE column, but that's not what I want, since SIZE can be huge with no ill effects. memoryuse & datasize limits don't seem to be RES either.
 
Just so we're starting on the same page, from top(1):
RES is the current amount of resident
memory (both SIZE and RES are given in kilobytes)

To solve your problem, I would set up a special user class in login.conf(5), and then join the user(s) who need this memory restriction to that class.

I think top(1)'s 'RES' is synonymous with login.conf(5)'s 'memorylocked' resource. But you will need to test to see whether that is true.
 
Use "memoryuse" for limiting Resident Set Size

anomie said:
I think top(1)'s 'RES' is synonymous with login.conf(5)'s 'memorylocked' resource. But you will need to test to see whether that is true.

A grep over the source shows:

Code:
./lib/libutil/login_class.c:    { "memoryuse",       login_getcapsize, RLIMIT_RSS     },

so memoryuse is what we're looking for (see also setrlimit(2))
 
For some reason limits -m 3m (memoryuse) allows the process to pass that limit (top's RES column) indefinitely and continue running.
But limits -v 30m (virtualmem) does cause a core dump.
 
I was going to remind you not to necro-bump because this thread is 11 years old, but you are the OP :) You don't see many posts with that time gap and the OP actually responds.
 
Back
Top