From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 18 09:30:27 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1646216A4CE for ; Fri, 18 Feb 2005 09:30:27 +0000 (GMT) Received: from smtp.ucla.edu (smtp.ucla.edu [169.232.48.136]) by mx1.FreeBSD.org (Postfix) with ESMTP id C703F43D58 for ; Fri, 18 Feb 2005 09:30:26 +0000 (GMT) (envelope-from ashcs@ucla.edu) Received: from mail.ucla.edu (mail.ucla.edu [169.232.48.135]) by smtp.ucla.edu (8.13.1/8.13.1) with ESMTP id j1I9UL5C010167 for ; Fri, 18 Feb 2005 01:30:21 -0800 Received: from ash (s226-171.resnet.ucla.edu [164.67.226.171]) (authenticated bits=0) by mail.ucla.edu (8.13.3/8.13.3) with ESMTP id j1I9UQIJ015377 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Fri, 18 Feb 2005 01:30:26 -0800 Message-ID: <001001c5159c$8369aef0$abe243a4@ash> From: "Ashwin Chandra" To: Date: Fri, 18 Feb 2005 01:30:41 -0800 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Probable-Spam: no X-Spam-Hits: 0.528 X-Scanned-By: smtp.ucla.edu Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.1 Subject: Memory Accounting in Proc.h X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2005 09:30:27 -0000 I am trying to get the fields ru_idrss, and ru_isrss to see the the = current stack and data sizes for each process thats running in user = space. I read up on getrusage which says that ru_idrss and ru_isrss are = measured in kilobytes * the number of clock ticks. So I wanted to = retrieve the actual value in just KB by using a timeval struct that gets = the user and system ticks and takes the structure fields and divides by = this to get Kb. (similar to how it is done in kern_acct.c). Upon doing = this, the memory printouts seem to be inflated or not workign very well. = For example I wrote a program as follows: main() { int a[1000000]; while(1) {} } This initializes 4Mb of space on the stack. However when I print out the = memory portion (Data +stack)/4 (since ru_irss and ru_drss are both = multipled by PAGESIZE/1024, i get the value as around 173,000. If i take = out the int delcaration and just have a while loop I still get around = the same number (a little less). Do you know why this is? How can I accurately keep tabs of current memory usage per process? Ash