From owner-freebsd-stable@FreeBSD.ORG Mon Dec 20 20:02:57 2010 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B7AD51065673 for ; Mon, 20 Dec 2010 20:02:57 +0000 (UTC) (envelope-from kometen@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6AA158FC0C for ; Mon, 20 Dec 2010 20:02:57 +0000 (UTC) Received: by qwj9 with SMTP id 9so3013228qwj.13 for ; Mon, 20 Dec 2010 12:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=uajgo5xLe+vXkuNTFGP4rTr5T7VU5vflGMVF1yJFzBo=; b=UGHoW+wiQpsWm0WE79iA2/BWTm5AA/q1zi8V4C4+x2nkVqHANyK386iBYjly5pxjBt op06v3VRgHmO2aSYSsP8IbjecyGdFxjxMm+2h93LstJCPx8P1mabelG9pYx4gdHwWEn6 2P52WaNjjQGmo8XRFLdkBum95NIxdc4Xt31tc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=xnCCPsmzPymUyTm5UGUesdqM4YtjXfNG8QQDKBFl7YLlilVe7Lv8H3F8DUaNYhhtyj khu/pU1uXraklmnpaAM/1KJFy4FEdDGgITEGtc1oe09wThpHNkHcHOtERSLK0zfOSsM2 RzrHqmJi8uifNdbdj6nOpCgTTMAdB3lQ7N/fw= MIME-Version: 1.0 Received: by 10.229.245.5 with SMTP id ls5mr4134745qcb.176.1292875376398; Mon, 20 Dec 2010 12:02:56 -0800 (PST) Received: by 10.229.95.205 with HTTP; Mon, 20 Dec 2010 12:02:56 -0800 (PST) In-Reply-To: <201012201457.oBKEvObO035605@lurza.secnetix.de> References: <201012201457.oBKEvObO035605@lurza.secnetix.de> Date: Mon, 20 Dec 2010 21:02:56 +0100 Message-ID: From: Claus Guttesen To: FreeBSD Stable Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: get ram usage using getrusage() X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Dec 2010 20:02:57 -0000 > The "SIZE" column of top(1) is the same as the "VSZ" column > of ps(1): =A0It displays the virtual process size. =A0Basically > this is the sum of all VM mappings that are assigned to the > process. =A0It has _nothing_ to do with the RAM usage. > > Somewhat more useful for your purpose is the resident set > size ("RES" in top, "RSS" in ps). =A0This is the amount of > memory actually in use. =A0But this also includes files that > were mmap()ed, including libraries shared between many > processes. =A0I'm not sure this is what you want. =A0Another > problem is that the resident set size does NOT include > pages in swap. =A0So, if your process is swapped completely, > the RSS is zero, as you can see here: > > =A0PID USERNAME THR PRI NICE =A0SIZE RES STATE TIME =A0 WCPU COMMAND > 14388 olli =A0 =A0 =A0 1 =A0 5 =A0 =A00 3864K =A00K ttyin 0:00 =A00.00% <= zsh> Thank you (vielen dank :-) ) for your explanation. > If you free an object with the free() function, the pages > are not necessarily unmapped immediately. =A0This depends on > the malloc implementation and configuration. =A0Also, even > if it is unmapped, the rusage statistics are not updated > immediately (this depends on the statclock, see ``sysctl > kern.clockrate''). > > I think that applications should better track their memory > usage themselves, so it is portable and independent of > implementation details of the VM system and malloc library. > That's what most applications do, for example squid. I get a clearer picture (had to read your reply a couple of times) but I'm on my way. --=20 regards Claus When lenity and cruelty play for a kingdom, the gentler gamester is the soonest winner. Shakespeare twitter.com/kometen