Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I set a RAM limit for a specific user? I have tried editing the /etc/security/limits.conf file, and the RAM limits there, but I still see a users process exceeding the limit set.

I know that the limits are specified in kb, so I'm not using an incorrect number.

For instance, I am trying to set it so that a user can't use more than 2,048mb (or 2,097,152kb) of memory, and their program will use like 2500mb.

Is there any way that I can accomplish this without virtual machines? I am also trying to stay away from running virtual machines as an option.

Here's my /etc/sysconfig/limits.conf.

Also, the RSS limit is ignored since the kernel version I'm running is 2.6.18

share|improve this question

migrated from stackoverflow.com Feb 26 '12 at 6:21

This question came from our site for professional and enthusiast programmers.

    
Q: Is there any way that I can accomplish this without virtual machines? A: I don't think so :) –  paulsm4 Feb 26 '12 at 4:52
    
can you post your /etc/security/limits.conf file? –  jdizzle Feb 26 '12 at 5:04
    
I edited it with a pastebin link to the file. –  Trey G. Feb 26 '12 at 5:09
add comment

1 Answer

The controls related to memory are enforced via per process resource limits. The process limits related to memory have been partly broken for a long time under Linux. Example:

$ (ulimit -m 1; emacs)

If Emacs starts up, clearly the RSS resource limit is not being enforced. The limits that I have seen work are the data segment and stack limits.

$ (ulimit -d 1; emacs)
emacs: Memory exhausted--use M-x save-some-buffers RET
$ (ulimit -s 1; emacs)
$

So use only the "data" and "stack" memory limits, since these seem to be enforced.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.