From owner-freebsd-current@FreeBSD.ORG Thu Jun 8 07:50:12 2006 Return-Path: X-Original-To: current@FreeBSD.ORG Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8762B16B329 for ; Thu, 8 Jun 2006 05:18:45 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail.digifonica.com (mail.digifonica.com [69.90.104.235]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2618C43D4C for ; Thu, 8 Jun 2006 05:18:44 +0000 (GMT) (envelope-from sobomax@sippysoft.com) Received: from localhost (localhost.digifonica.com [127.0.0.1]) by mail.digifonica.com (Postfix) with ESMTP id 3B45D5C3C; Wed, 7 Jun 2006 22:18:44 -0700 (PDT) X-Virus-Scanned: amavisd-new at digifonica.com Received: from mail.digifonica.com ([127.0.0.1]) by localhost (mail.digifonica.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7J9H3xwA8As8; Wed, 7 Jun 2006 22:18:43 -0700 (PDT) Received: from [192.168.1.5] (S0106000f3d63befd.vs.shawcable.net [70.71.19.119]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.digifonica.com (Postfix) with ESMTP id 897245C33; Wed, 7 Jun 2006 22:18:43 -0700 (PDT) Message-ID: <4487B334.60203@sippysoft.com> Date: Wed, 07 Jun 2006 22:18:44 -0700 From: Maksym Sobolyev User-Agent: Thunderbird 1.5.0.4 (Macintosh/20060530) MIME-Version: 1.0 To: Mikhail Teterin References: <200606071827.24207.mi+mx@aldan.algebra.com> In-Reply-To: <200606071827.24207.mi+mx@aldan.algebra.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Thu, 08 Jun 2006 11:49:35 +0000 Cc: current@FreeBSD.ORG Subject: Re: getrusage() -- negative ru_maxrss?! X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 07:50:14 -0000 Looks like you are just overflowing long, which is 32bits on i386. You are multiplying size in kilobytes by 4K, in 32 bit math, which as it can be easily seen will overflow 2^^31 limit and therefore go negative when maxrss is more than 512K. -Maxim Mikhail Teterin wrote: > Hello! > > I have a program, which uses getrusage() to report its own performance before > exiting. > > I noticed recently, that the ru_maxrss field is sometimes reported negative -- > I don't think, I ever saw this last year, for example... Is the field > considered usable and (semi-)accurate, or did FreeBSD abandon it (as Solaris > did)? > > I currently print it as: > > fprintf(..., "... used %ld Kb ...", ... ru.ru_maxrss*getpagesize()/1024... ); > > What's the right way to do it? > > -mi > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > >