I'm running a simulator and I'm noticing an slow increase in memory for long simulations such that the simulation has to end because of a lack of memory. A colleague of mine ran Valgrind memcheck and reported that nothing of interest was reported other than known mem leaks. My advisor suggested that I try adding getrusage() at suspicious places in the code to try and pinpoint where the leak is occurring in the simulator. I recently tried this only to discover that Unix doesn't fully support getrusage() anymore and it doesn't seem like it will be useful for obtaining memory usage. I know I can use system() to issue a cat and grep to get the mem usage from /proc/pid/status (and I'm not sure if this would be accurate since I guess the system would fork a thread and make that call while the main thread continues?), but I was wondering if there was a better way of determining the memory usage at a particular point in the code. Most of the other solutions I've seen are scripts and would not be able to tell you the difference in memory usage between two different points in the code.
The compute node that I'm running the simulator on is running a recent Ubuntu 64 bit version. Running uname -a yields:
Linux power1 2.6.24-19-generic #1 SMP Wed Aug 20 17:53:40 UTC 2008 x86_64 GNU/Linux
I was not aware of the XOPEN thing. When I did man getrusage, the information didn't say anything about XOPEN. Is this specific to UNIX?
I only did a man getrusage, is there someplace else I should be looking?