Gentoo Archives: gentoo-user

From: Zhang Weiwu <zhangweiwu@××××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] limit maximum memory size of any process
Date: Tue, 04 Nov 2008 07:31:01
Message-Id: 490FFA2F.9010705@realss.com
1 Matthias Bethke wrote:
2 > Hi Zhang,
3 > on Mon, Nov 03, 2008 at 06:24:00PM +0800, you wrote:
4 >> I hope I can configure the system so that any process uses more than 50%
5 >> of memory are automatically killed. first I was recommend to use ulimit
6 >> by googling around. However this seems doesn't work even if I set both
7 >> -d and -m (here is my .xinitrc)
8 >>
9 >> ~$ cat .xinitrc
10 >> #export XMODIFIERS=@im=FCITX
11 >> #fcitx &
12 >> ulimit -d 300000
13 >> ulimit -m 300
14 >> exec /usr/bin/fluxbox
15 >>
16 >>
17 >> Result: OpenOffice stands still even when it takes 80% memory (read from
18 >> top).
19 >> So: is ulimit the solution? If so, what option should I set?
20 >
21 > I interpret the above as "use a maximum of 300,000 KiB of memory, of
22 > which 300 may be resident (i.e. in physical memory) and 299,700 swapped
23 > out." That doesn't sound good, although I'm not sure I'm reading it
24 > correctly.
25
26 Sorry, it seems I used these parameter without care. I guess I only need
27 to set physical memory limit, a.k.a. resident memory.
28
29 OT: I don't know why I have
30 max locked memory (kbytes, -l) 32
31 But it has been like that before I set ulimit.
32
33
34 > What I do is use /etc/sercurity/limits.conf (from pam_limits) with a
35 > couple of entries like those:
36 > | @users hard nproc 1000
37 > | mb hard nproc 5000
38 > | @users hard as 2097152
39 > | mb hard as 6291456
40 > | mb hard nice -5
41 > | mb hard rtprio 5
42 > Meaning, everyone but me (mb) may use up to 1000 processes per login,
43 > with a max. address space of 2 GiB each; for myself the limit is 6 GiB
44 > and 5k processes. Myself I cannot accidentially set a negative
45 > nice-value because I left the soft limit at its default (0 for non-root
46 > users) but using ulimit I can set it to the hard limit of -5 and nice-up
47 > processes even as a normal user.
48
49 I don't have a file called /etc/sercurity/limits.conf and neither can I
50 find information about it by using 'man limits.conf'. Further I couldn't
51 find a package called pam_limits to emerge. Can you give me some clue which
52 package I should emerge in order to set limits.conf ?
53
54 Thank you very much for prompt help!

Replies

Subject Author
Re: [gentoo-user] limit maximum memory size of any process Matthias Bethke <matthias@×××××××.de>