From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 21 10:26:30 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3192D106564A for ; Fri, 21 Oct 2011 10:26:30 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mx1.freebsd.org (Postfix) with ESMTP id AEA228FC16 for ; Fri, 21 Oct 2011 10:26:29 +0000 (UTC) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RHCJ2-0002Bl-J7 for freebsd-hackers@freebsd.org; Fri, 21 Oct 2011 12:26:28 +0200 Received: from lara.cc.fer.hr ([161.53.72.113]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Oct 2011 12:26:28 +0200 Received: from ivoras by lara.cc.fer.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 21 Oct 2011 12:26:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-hackers@freebsd.org From: Ivan Voras Date: Fri, 21 Oct 2011 12:26:17 +0200 Lines: 49 Message-ID: References: <4EA0610B.90206@gmail.com> <20111021084413.GA46039@server.vk2pj.dyndns.org> <4EA1471E.9050501@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC69AF980CD066BDBF1788C0A" X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: lara.cc.fer.hr User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:7.0.1) Gecko/20111004 Thunderbird/7.0.1 In-Reply-To: <4EA1471E.9050501@gmail.com> X-Enigmail-Version: 1.1.2 Subject: Re: Measuring memory footprint in C/C++ code on FreeBSD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2011 10:26:30 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC69AF980CD066BDBF1788C0A Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 21/10/2011 12:19, Razmig K wrote: > Le 21.10.2011 10:44, Peter Jeremy a =C3=A9crit : >> On 2011-Oct-20 19:57:31 +0200, Razmig K 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 childr= en. >=20 >> >> 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. >=20 > 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. --------------enigC69AF980CD066BDBF1788C0A 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/ iEYEARECAAYFAk6hSMkACgkQldnAQVacBchCngCgy6qNnCqLWK4oZyde6It+J+SG CgsAnjXMjfNGvEgqmZ571ZOOzq4uEQVG =q+by -----END PGP SIGNATURE----- --------------enigC69AF980CD066BDBF1788C0A--