From owner-freebsd-stable@FreeBSD.ORG Thu Mar 2 23:50:32 2006 Return-Path: X-Original-To: stable@freebsd.org Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E952316A420; Thu, 2 Mar 2006 23:50:32 +0000 (GMT) (envelope-from nb@ravenbrook.com) Received: from raven.ravenbrook.com (raven.ravenbrook.com [193.82.131.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E57143D45; Thu, 2 Mar 2006 23:50:31 +0000 (GMT) (envelope-from nb@ravenbrook.com) Received: from thrush.ravenbrook.com (thrush.ravenbrook.com [193.112.141.145]) by raven.ravenbrook.com (8.12.6p3/8.12.6) with ESMTP id k22NoTqV043130; Thu, 2 Mar 2006 23:50:29 GMT (envelope-from nb@ravenbrook.com) Received: from thrush.ravenbrook.com (localhost [127.0.0.1]) by thrush.ravenbrook.com (8.13.4/8.13.4) with ESMTP id k22NoTFu080814; Thu, 2 Mar 2006 23:50:29 GMT (envelope-from nb@thrush.ravenbrook.com) From: Nick Barnes To: Nik Clayton In-Reply-To: <44077091.3060604@freebsd.org> from Nik Clayton of "Thu, 02 Mar 2006 22:24:17 +0000" Date: Thu, 02 Mar 2006 23:50:29 +0000 Message-ID: <80813.1141343429@thrush.ravenbrook.com> Sender: nb@ravenbrook.com Cc: stable@freebsd.org Subject: Re: Failing to understand 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: Thu, 02 Mar 2006 23:50:33 -0000 At 2006-03-02 22:24:17+0000, Nik Clayton writes: > I'm failing to understand how getrusage() works, which is a bit perplexing, > because it doesn't seem like it would be terribly complicated. ru_maxrss is the maximum resident set size, not the heap size. malloc(big) doesn't grow the resident set. Touching the memory you have allocated will grow the resident set. Try this: getrusage(RUSAGE_SELF, &ru); printf("%lu\n", ru.ru_maxrss); p = malloc(SIZE); assert(p) getrusage(RUSAGE_SELF, &ru); printf("%lu\n", ru.ru_maxrss); for (i=0; i