Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Oct 2011 12:26:17 +0200
From:      Ivan Voras <ivoras@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Measuring memory footprint in C/C++ code on FreeBSD
Message-ID:  <j7rhc9$bvb$1@dough.gmane.org>
In-Reply-To: <4EA1471E.9050501@gmail.com>
References:  <4EA0610B.90206@gmail.com> <20111021084413.GA46039@server.vk2pj.dyndns.org> <4EA1471E.9050501@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 21/10/2011 12:19, Razmig K wrote:
> Le 21.10.2011 10:44, Peter Jeremy a écrit :
>> On 2011-Oct-20 19:57:31 +0200, Razmig K<strontium90@gmail.com>  wrote:
>> It's not clear whether the program is attempting to determine it's
>> own (or a child's) memory footprint, or that of an arbitrary process.
>> In the former case, getrusage() is the obvious choice.  This as a
>> portable interface.
> The program has to determine its own memory footprint. It has no children.
> 
>>
>> If you want to examine arbitrary processes, the best interface on
>> FreeBSD would be kvm_getprocs(3).
>>
>> BTW, since you mention heap objects, I presume you are aware that
>> malloc() uses mmap(), rather than sbrk() to obtain memory.
> No I wasn't aware of that.
> 
> In few words, the program needs to obtain and report information
> reported by the SIZE column of top, since it is going to be run many
> times, and it is impractical to watch top for this purpose.

Well, do you know that SIZE in top is virtual memory size, not resident
size (which is the "RES" column)? You can allocate whatever you want
from virtual memory, it is not "used" until it's touched.



[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6hSMkACgkQldnAQVacBchCngCgy6qNnCqLWK4oZyde6It+J+SG
CgsAnjXMjfNGvEgqmZ571ZOOzq4uEQVG
=q+by
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?j7rhc9$bvb$1>