Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to limit the memory consumption on a linux system? I would prefer a per user solution but a per process solution would be better than no limitation at all.

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

The solution to your problem is the PAM module of libcg. Precisions follow:

On recent kernels this can be controlled by the "Control Groups" (cgroup). It's a feature that have to be compiled in kernel. The userland library is named libcg (package cgroup-bin on debian/ubuntu, please comment for other distros). There are various utilities that can plug in.

When a process spawn another one, the new one inherits the control group of its parent. Memory consumption (as well as cpu, which core, and more) are affected by control group.

share|improve this answer
    
thanks. I'm going to try it. I tried using ulimit (pam_limits) before but that doesn't work nowadays. –  joke Nov 21 '10 at 19:54
    
works perfectly. although cgroups are little bit hard to configure. But as soon as you understand how it works you can limit users memory consumption for swap and real memory individually. –  joke Nov 21 '10 at 23:06
add comment

Using pam_limits may help with per user limits for some memory related settings. The limits are set in the /etc/security/limits.conf file.

share|improve this answer
    
It tried using pam_limits (ulimit) but it doesn't work on recent kernel because they don't restrict limits to rss any more. –  joke Nov 21 '10 at 19:53
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.