• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
getrusage only partially working?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: getrusage only partially working?
      • From: Terry Lambert <email@hidden>
  • Prev by Date: RE: rusage data for another process?
  • Next by Date: CFLite Leopard CF-476
  • Previous by thread: My exception handler can't work with 10.4 SDK on Leopar
  • Next by thread: Re: getrusage only partially working?
  • Index(es):
    • Date
    • Thread