How to get the memory usage of myself process (GetProcessMemoryInfo() 4 linux)?
I need to know the virtual memory usage, the page faults, and other memory related information in a linux/c++ program.
I need it to be posix-portable so I would try to avoid reading /proc/self/stat or /proc/self/statm because it is kernel/platform dependent.
In windows there's a function GetProcessMemoryInfo(), and GlobalMemoryStatus() which are pretty good for that.
Is there something similar in c/c++/linux?
Check the getrusage(2) manpage but note the caveats.
That's just the thing that I was looking for :).
Now I've the issue that I when I call getrusage(), the structure is filled with 0, except for two fields, that already have wrong values :(.
I'm using RHEL 5.3 distro, and ldd for my program (procstat) tells me:
libc.so.6 => /lib64/libc.so.6 (0x0000003ab0000000)
and my libc.so.6 already points to libc-2.5.so
Also tested the function mallinfo from malloc.h, and the problem was the same. It compile, but in the runtime it fills the structure with zero values.
|All times are GMT -5. The time now is 10:18 AM.|