From owner-freebsd-hackers@FreeBSD.ORG Fri Oct 21 10:19:13 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 C6B481065744 for ; Fri, 21 Oct 2011 10:19:13 +0000 (UTC) (envelope-from strontium90@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5C88B8FC0A for ; Fri, 21 Oct 2011 10:19:12 +0000 (UTC) Received: by wyi40 with SMTP id 40so4925166wyi.13 for ; Fri, 21 Oct 2011 03:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=QZ9WpmKh82h/DhKCBly23aZcbir65rMjoxwjKu5X6Gc=; b=GqZZgpHTbpy3q/HnmovkyqZlHrpuf5Ihmrb3rWkjjKEp0IuzKIgEH/G96vOp80djd5 dmz82UUwjdeNh6uHxHqGifqIGwHYiWmnP+3E7X7uopcVafwL8OVqyJqOADez1WYM9sLZ Lo5jLZz8YtD/yT2JkYoCy6A2JjlroiF6Uaw4U= Received: by 10.227.20.65 with SMTP id e1mr5168207wbb.105.1319192351994; Fri, 21 Oct 2011 03:19:11 -0700 (PDT) Received: from iv-sv-328.creatis.insa-lyon.fr (iv-sv-328.creatis.insa-lyon.fr. [195.220.108.195]) by mx.google.com with ESMTPS id l42sm1940142wbn.16.2011.10.21.03.19.11 (version=SSLv3 cipher=OTHER); Fri, 21 Oct 2011 03:19:11 -0700 (PDT) Message-ID: <4EA1471E.9050501@gmail.com> Date: Fri, 21 Oct 2011 12:19:10 +0200 From: Razmig K User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:7.0) Gecko/20111003 Thunderbird/7.0 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <4EA0610B.90206@gmail.com> <20111021084413.GA46039@server.vk2pj.dyndns.org> In-Reply-To: <20111021084413.GA46039@server.vk2pj.dyndns.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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:19:13 -0000 Le 21.10.2011 10:44, Peter Jeremy a écrit : > 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 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. Thanks. ~Razmig