Skip site navigation (1)Skip section navigation (2)
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): =A0It displays the virtual process size. =A0Basically
> this is the sum of all VM mappings that are assigned to the
> process. =A0It 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). =A0This is the amount of
> memory actually in use. =A0But this also includes files that
> were mmap()ed, including libraries shared between many
> processes. =A0I'm not sure this is what you want. =A0Another
> problem is that the resident set size does NOT include
> pages in swap. =A0So, if your process is swapped completely,
> the RSS is zero, as you can see here:
>
> =A0PID USERNAME THR PRI NICE =A0SIZE RES STATE TIME =A0 WCPU COMMAND
> 14388 olli =A0 =A0 =A0 1 =A0 5 =A0 =A00 3864K =A00K ttyin 0:00 =A00.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. =A0This depends on
> the malloc implementation and configuration. =A0Also, 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.

--=20
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>