I used the getrusage function from the GNU C library, but
unfortunately the kernel we are using (linux 2.6) is not supporting the
fields for memory usage in the rusage structure.
After some search I started to use the /proc file system and the statm
file related to the pid of the running program.
Now I have inserted throughout the program several calls to a function
that prints the statistics from the statm file in order to isolate the
increase of memory usage.
Unfortunately the result points to a part of the program that does not
have any hidden ambiguities related to memory usage, which is also
confirmed by isolating it in a test program.
Now my questions:
- is there any replacement to the getrusage function?
- is there any alternative method to figure out the memory usage of the
program within the program itself?
- is there any where explained how the GNU/Linux system updates the
statm file and how much it is reliable at spotting increasing memory usage?
Thanks for any suggestion.
Al
p.s.: my apologies for the cross-posting, I also posted a similar
article to the comp.lang.c but I was advised to search somewhere else,
since none of those questions where C related.
--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
thanks a lot for pointing that out. I didn't know the mtrace() function
and, even though I struggled a bit to find out glibc-utils was not
installed on my system, is a nice to have.
Unfortunately the outcome is either unreadable (even using two
parameters) or not very useful at least so far.
It would be useful to "print" on the stdout the evolution of the memory
usage at the time it is increased, in order to trace it while running.
> Chris