monit-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: total memory of children processes


From: Martin Pala
Subject: Re: total memory of children processes
Date: Wed, 10 Sep 2003 18:35:14 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030908 Debian/1.4-4

I see the same problem on my station too:

unicorn:~/cvs/monit# ps -leaf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD 1 S root 4890 1 0 69 0 - 2604 rt_sig 18:23 ? 00:00:00 /usr/sbin/slapd 1 S root 4891 4890 0 69 0 - 2604 poll 18:23 ? 00:00:00 /usr/sbin/slapd 1 S root 4892 4891 0 69 0 - 2604 select 18:23 ? 00:00:00 /usr/sbin/slapd 1 S root 4913 4891 0 69 0 - 2604 rt_sig 18:24 ? 00:00:00 /usr/sbin/slapd

unicorn:~/cvs/monit# ./monit -c /etc/monitrc status
Process 'slapd' is running with pid [4890]
       Uptime: 3m  CPU: 0.0% Memory w/o children: 0.8% [2604kB]
       Children: 3 Memory w/ children: 3.2% [10416kB]
       Monitoring status: monitored

As you can see, the reported size is sum of RSS off all threads (4*2604=10416). This is not correct result, because 2604kB is memory shared by threads (LinuxThreads reports each thread with its PID and size, but the memory is shared).


Note: this is not related to /proc/kcore patch - it only replaced method for available memory detection (instead of kcore size it is read from /proc/meminfo - the result is the same) => this is standalone problem (bug).

Martin


Arkadiusz Miskiewicz wrote:

Hi,

Total memory of children processes seems miscalculated:
Event: total mem amount of 12193680kB matches resource limit [total mem amount>512001kB]

ok but this machine has only 512MB ram and 2GB of swap.

The problem seems be that only rss (resident set size) value is used. rss also includes memory shared between processes.

IMO algoritm to calculate total mem amount should looke like:

rss of parent + (rss of first child - shared mem, rss of second chold - shared mem and so on). It's still not perfect because we don't know between which processes that memory is shared but it's much better than adding whole rss.

shared memory can be found in /proc/$pid/statm.

On my server for httpd proces it's:
address@hidden root]# pmap -x 22746 |less
22746:   httpd -4
Address       kB Resident Shared Private Permissions       Name
00110000      80       -       0      80 read/exec         ld-2.2.5.so
00124000       4       -       0       4 read/write        ld-2.2.5.so
00125000       8       -       0       8 read/write         [ anon ]
00128000       4       -       0       4 read/exec         mod_asis.so
[...]
01142000     980       -     980       0 read/write        mod_jk2.shm
01237000     980       -     980       0 read/write        mod_jk2.shm
0132c000 508 - 508 0 read/write SYSV00000000 (deleted) 013ab000 364 - 364 0 read/write SYSV00000000 (deleted)
08048000     212       -       0     212 read/exec         httpd
0807d000      32       -       0      32 read/write        httpd
08085000   63820       -       0   63820 read/write/exec    [ anon ]
40000000 32768 - 32768 0 read/write SYSV00000000 (deleted) 42000000 32768 - 32768 0 read/write SYSV00000000 (deleted)
bfff5000      44       -       0      44 read/write/exec    [ anon ]
--------  ------  ------  ------  ------
total kB  148912       -   71360   77552

so almost half of memory used by this process is shared between httpd (and other) processes...

Comments?






reply via email to

[Prev in Thread] Current Thread [Next in Thread]