Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Feb 2005 01:30:41 -0800
From:      "Ashwin Chandra" <ashcs@ucla.edu>
To:        <freebsd-hackers@freebsd.org>
Subject:   Memory Accounting in Proc.h
Message-ID:  <001001c5159c$8369aef0$abe243a4@ash>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001001c5159c$8369aef0$abe243a4>