Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Feb 2005 10:56:05 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Ashwin Chandra <ashcs@ucla.edu>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Memory Accounting in Proc.h
Message-ID:  <20050218165603.GA3752@dan.emsphone.com>
In-Reply-To: <001001c5159c$8369aef0$abe243a4@ash>
References:  <001001c5159c$8369aef0$abe243a4@ash>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Feb 18), Ashwin Chandra said:
> 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?

Possibly the compilter has optimized 'a' away since you neither read
from or write to it?  Try memset'ing it to zero and see if your numbers
change.

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050218165603.GA3752>