2

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.

2 Answers 2

8

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.

2
  • thanks. I'm going to try it. I tried using ulimit (pam_limits) before but that doesn't work nowadays.
    – joke
    Nov 21, 2010 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, 2010 at 23:06
1

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.

1
  • 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, 2010 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .