Gentoo Archives: gentoo-user

From: Zhang Weiwu <zhangweiwu@××××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] limit maximum memory size of any process
Date: Mon, 03 Nov 2008 10:24:06
Message-Id: 490ED140.8030109@realss.com
1 Hello.
2
3 In my daily us of computer any process that takes more than 50% of the
4 memory (I read from top, not knowing if this is 50% of 384MB physical or
5 50% of having 800MB swap counted in) must have gone wrong, and usually
6 drag performance down to such extent that killing it is impossible
7 (because not possible to launch a terminal window to type kill -TERM).
8 Examples are:
9
10 1. Firefox opens a broken website that wish to send 10M binary
11 content to the browser window;
12 2. OpenOffice opens a document incorrectly;
13 3. Mistake in Java software (usually it keep eating memory);
14
15 I hope I can configure the system so that any process uses more than 50%
16 of memory are automatically killed. first I was recommend to use ulimit
17 by googling around. However this seems doesn't work even if I set both
18 -d and -m (here is my .xinitrc)
19
20 ~$ cat .xinitrc
21 #export XMODIFIERS=@im=FCITX
22 #fcitx &
23 ulimit -d 300000
24 ulimit -m 300
25 exec /usr/bin/fluxbox
26
27
28 Result: OpenOffice stands still even when it takes 80% memory (read from
29 top).
30 So: is ulimit the solution? If so, what option should I set? My current
31 ulimit is:
32
33 $ ulimit -a
34 core file size (blocks, -c) 0
35 data seg size (kbytes, -d) 300000
36 scheduling priority (-e) 0
37 file size (blocks, -f) unlimited
38 pending signals (-i) 3072
39 max locked memory (kbytes, -l) 32
40 max memory size (kbytes, -m) 300
41 open files (-n) 1024
42 pipe size (512 bytes, -p) 8
43 POSIX message queues (bytes, -q) 819200
44 real-time priority (-r) 0
45 stack size (kbytes, -s) 8192
46 cpu time (seconds, -t) unlimited
47 max user processes (-u) 3072
48 virtual memory (kbytes, -v) unlimited
49 file locks (-x) unlimited
50
51
52 --
53 Real Softservice
54
55 Huateng Tower, Unit 1788
56 Jia 302 3rd area of Jinsong, Chao Yang
57
58 Tel: +86 (10) 8773 0650 ext 603
59 Mobile: 159 1111 7382
60 http://www.realss.com

Replies

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