Re: Measuring memory footprint in C/C++ code on FreeBSD
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig75685E8576A963ABF750171C
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On 21/10/2011 12:57, Razmig K wrote:
> Le 21.10.2011 12:26, Ivan Voras a =C3=A9crit :
>> Well, do you know that SIZE in top is virtual memory size, not residen=
t
>> size (which is the "RES" column)? You can allocate whatever you want
>> from virtual memory, it is not "used" until it's touched.
>=20
> Yes, I do. So do you suggest using RES as a better indicator of memory
> footprint?
Almost certainly yes. Measuring virtual memory is significantly less
important for real-world loads. Some of this is very nicely described
here: https://www.varnish-cache.org/trac/wiki/ArchitectNotes .
> The program in question processes large 3D images via vtk, and I'd like=
> to measure its memory usgae with different parameter configurations as
> the maximum amount of memory acquired during execution. Since SIZE ofte=
n
> happens to be larger than RES, and increase more during execution, I
> thought of using it as an indicator of memory footprint.
No; the difference between SIZE and RES is "slack space" - allocated but
untouched virtual memory, which is *NOT PRESENT IN RAM*. You can verify
this yourself: make a small C program and allocate twice the physical
memory (+swap) you have on the machine (try terabytes on a 64-bit
machine), and it will succeed. If you look at this program in top, it
should (barring some optimizations) show you that SIZE is huge, but RES
is a couple of MB, basically like you didn't allocate anything at all.
Now, it is a whole other thing if you try to actually *use* this memory
you've allocated.
Here's a random link on the topic from Google:
http://opsmonkey.blogspot.com/2007/01/linux-memory-overcommit.html .
Unfortunately, the phrase "memory overcommit" has been hijacked by the
virtualization environment to mean the same thing but relating to the
memory in virtual machines.
--------------enig75685E8576A963ABF750171C
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk6hYL0ACgkQldnAQVacBch22QCg38zjUUahKydX8V5IFbeFXcDB
leMAniWcI5UM+w1YoZFlpqu8fstCp93v
=SRBe
-----END PGP SIGNATURE-----
--------------enig75685E8576A963ABF750171C--
討論串 (同標題文章)
完整討論串 (本文為第 8 之 11 篇):