1 |
Hi Zhang, |
2 |
on Mon, Nov 03, 2008 at 06:24:00PM +0800, you wrote: |
3 |
> I hope I can configure the system so that any process uses more than 50% |
4 |
> of memory are automatically killed. first I was recommend to use ulimit |
5 |
> by googling around. However this seems doesn't work even if I set both |
6 |
> -d and -m (here is my .xinitrc) |
7 |
> |
8 |
> ~$ cat .xinitrc |
9 |
> #export XMODIFIERS=@im=FCITX |
10 |
> #fcitx & |
11 |
> ulimit -d 300000 |
12 |
> ulimit -m 300 |
13 |
> exec /usr/bin/fluxbox |
14 |
> |
15 |
> |
16 |
> Result: OpenOffice stands still even when it takes 80% memory (read from |
17 |
> top). |
18 |
> So: is ulimit the solution? If so, what option should I set? |
19 |
|
20 |
I interpret the above as "use a maximum of 300,000 KiB of memory, of |
21 |
which 300 may be resident (i.e. in physical memory) and 299,700 swapped |
22 |
out." That doesn't sound good, although I'm not sure I'm reading it |
23 |
correctly. |
24 |
What I do is use /etc/sercurity/limits.conf (from pam_limits) with a |
25 |
couple of entries like those: |
26 |
| @users hard nproc 1000 |
27 |
| mb hard nproc 5000 |
28 |
| @users hard as 2097152 |
29 |
| mb hard as 6291456 |
30 |
| mb hard nice -5 |
31 |
| mb hard rtprio 5 |
32 |
Meaning, everyone but me (mb) may use up to 1000 processes per login, |
33 |
with a max. address space of 2 GiB each; for myself the limit is 6 GiB |
34 |
and 5k processes. Myself I cannot accidentially set a negative |
35 |
nice-value because I left the soft limit at its default (0 for non-root |
36 |
users) but using ulimit I can set it to the hard limit of -5 and nice-up |
37 |
processes even as a normal user. |
38 |
|
39 |
cheers, |
40 |
Matthias |
41 |
-- |
42 |
I prefer encrypted and signed messages. KeyID: FAC37665 |
43 |
Fingerprint: 8C16 3F0A A6FC DF0D 19B0 8DEF 48D9 1700 FAC3 7665 |