From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 21 11:05:19 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 89BA3106564A for ; Fri, 21 Oct 2011 11:05:19 +0000 (UTC) (envelope-from peterjeremy@acm.org) Received: from fallbackmx06.syd.optusnet.com.au (fallbackmx06.syd.optusnet.com.au [211.29.132.8]) by mx1.freebsd.org (Postfix) with ESMTP id 199888FC08 for ; Fri, 21 Oct 2011 11:05:18 +0000 (UTC) Received: from mail26.syd.optusnet.com.au (mail26.syd.optusnet.com.au [211.29.133.167]) by fallbackmx06.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p9L9NYWX012246 for ; Fri, 21 Oct 2011 20:23:34 +1100 Received: from server.vk2pj.dyndns.org (c220-239-116-103.belrs4.nsw.optusnet.com.au [220.239.116.103]) by mail26.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id p9L9NUaZ019845 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 21 Oct 2011 20:23:32 +1100 X-Bogosity: Ham, spamicity=0.000000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.5/8.14.4) with ESMTP id p9L8iEjR046084; Fri, 21 Oct 2011 19:44:14 +1100 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.5/8.14.4/Submit) id p9L8iELu046083; Fri, 21 Oct 2011 19:44:14 +1100 (EST) (envelope-from peter) Date: Fri, 21 Oct 2011 19:44:13 +1100 From: Peter Jeremy To: Razmig K Message-ID: <20111021084413.GA46039@server.vk2pj.dyndns.org> References: <4EA0610B.90206@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline In-Reply-To: <4EA0610B.90206@gmail.com> X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org 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 11:05:19 -0000 --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2011-Oct-20 19:57:31 +0200, Razmig K wrote: > I'd like to measure the memory footprint in C/C++ code for a=20 >program running under FreeBSD and Linux in terms of total process size=20 >including heap objects. Due to execution length, I'd like to avoid the=20 >use of valgrind. 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. 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. --=20 Peter Jeremy --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk6hMN0ACgkQ/opHv/APuIeatQCglXjkBVAyxZ1bqGxU9gMHLthX 7noAoL4YBgGFaeg6b4HO8/SSpJI0AnHU =912H -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF--