Re: How do you accurately determine a process' RAM usage?

From: Mauricio Lin
Date: Tue Jul 19 2005 - 15:11:55 EST


Hi,

On 7/12/05, P@xxxxxxxxxxxxxx <P@xxxxxxxxxxxxxx> wrote:
> Andrew Morton wrote:
> > OK, please let us know how it goes.
>
> It went very well. I could find no problems at all.
> I've updated my script to use the new method, so please merge smaps :)
> http://www.pixelbeat.org/scripts/ps_mem.py
>
> Usually the shared mem reported by /proc/$$/statm
> is the same as summing all the shared values in in /proc/$$/smaps
> but there can be large discrepancies.

Have you checked how the statm shared is calculated? I guess it does
something like:
shared = mm->rss - mm->anon_rss

But in smaps output you can have anonymous area like:

b6e0e000-b6e13000 rw-p
Size: 20 KB
Rss: 4 KB
Shared_Clean: 0 KB
Shared_Dirty: 4 KB
Private_Clean: 0 KB
Private_Dirty: 0 KB

Look that it presents 4 KB of shared value in area considered anonymous.

ANDREW: anon_rss is the rss for anonymous area, right?

> In the real world you can see this with a newly started apache.
> On my system statm reported that apache was using 35MB,
> whereas smaps reported the correct amount of 11MB.

How dou you know that 11MB is the correct shared value and the 35MB
is the wrong value?

BR,

Mauricio Lin.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/