getrusage only partially working?
getrusage only partially working?
- Subject: getrusage only partially working?
- From: Mike Fischer <email@hidden>
- Date: Tue, 11 Dec 2007 16:26:05 +0100
Hi!
For some reason I can't seem to get getrusage(2) to work the way I
expect it to under 10.4.11 on a PPC G5 machine (haven't tested on
other machines).
I expected the memory related fields to show values other than 0
which more or less correlate with the actual memory usage of the
application. But what I am seeing is values of 0 only in each of
these fields (ru_maxrss, ru_ixrss, ru_idrss, ru_isrss).
Probably I'm doing something wrong, but what?
Here is my call to getrusage:
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
int main(int argc, const char *argv[])
{
struct rusage u;
int err = getrusage(RUSAGE_SELF,
&u);
if (0 == err)
{
double ut = u.ru_utime.tv_sec + u.ru_utime.tv_usec /
1000000.0;
double st = u.ru_stime.tv_sec + u.ru_stime.tv_usec /
1000000.0;
printf("ru_maxrss:0xx, ru_ixrss:0xx, ru_idrss:0xx,
ru_isrss:0xx, user:%f s, system:%f s\n",
u.ru_maxrss,
u.ru_ixrss,
u.ru_idrss,
u.ru_isrss,
ut,
st);
} else {
printf("ERROR: getrusage() returned:%d\n",
err);
}
return 0;
}
Compiled as a standard command line tool using Xcode 2.4.1 it outputs
something like this:
ru_maxrss:0x00000000, ru_ixrss:0x00000000, ru_idrss:0x00000000,
ru_isrss:0x00000000, user:0.129729 s, system:0.031769 s
If I call this in a loop which also allocates and writes to some
memory I see the user and system times increase but the other values
stay at 0.
Any ideas?
Thanks!
Mike
--
Mike Fischer Softwareentwicklung, EDV-Beratung
Schulung, Vertrieb
Web: <http://homepage.mac.com/mike_fischer/index.html>
Note: I read this list in digest mode!
Send me a private copy for faster responses.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden