Date: Mon, 20 Dec 2010 21:02:56 +0100 From: Claus Guttesen <kometen@gmail.com> To: FreeBSD Stable <freebsd-stable@freebsd.org> Subject: Re: get ram usage using getrusage() Message-ID: <AANLkTimYKLPh8sAhr%2B7Lx9pT0S8OV1rvDGBJz0sD_Dfs@mail.gmail.com> In-Reply-To: <201012201457.oBKEvObO035605@lurza.secnetix.de> References: <AANLkTimyL6gkHRMfv7z-2SMOL3hRar9b3h3D6Hwoqw9j@mail.gmail.com> <201012201457.oBKEvObO035605@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
> The "SIZE" column of top(1) is the same as the "VSZ" column
> of ps(1): It displays the virtual process size. Basically
> this is the sum of all VM mappings that are assigned to the
> process. It has _nothing_ to do with the RAM usage.
>
> Somewhat more useful for your purpose is the resident set
> size ("RES" in top, "RSS" in ps). This is the amount of
> memory actually in use. But this also includes files that
> were mmap()ed, including libraries shared between many
> processes. I'm not sure this is what you want. Another
> problem is that the resident set size does NOT include
> pages in swap. So, if your process is swapped completely,
> the RSS is zero, as you can see here:
>
> PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND
> 14388 olli 1 5 0 3864K 0K ttyin 0:00 0.00% <zsh>
Thank you (vielen dank :-) ) for your explanation.
> If you free an object with the free() function, the pages
> are not necessarily unmapped immediately. This depends on
> the malloc implementation and configuration. Also, even
> if it is unmapped, the rusage statistics are not updated
> immediately (this depends on the statclock, see ``sysctl
> kern.clockrate'').
>
> I think that applications should better track their memory
> usage themselves, so it is portable and independent of
> implementation details of the VM system and malloc library.
> That's what most applications do, for example squid.
I get a clearer picture (had to read your reply a couple of times) but
I'm on my way.
--
regards
Claus
When lenity and cruelty play for a kingdom,
the gentler gamester is the soonest winner.
Shakespeare
twitter.com/kometen
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTimYKLPh8sAhr%2B7Lx9pT0S8OV1rvDGBJz0sD_Dfs>
