Hey everybody,
Do any of you know of a way to monitor the memory usage of your C++ program in Linux from within your program?
Thank you for your help.
Printable View
Hey everybody,
Do any of you know of a way to monitor the memory usage of your C++ program in Linux from within your program?
Thank you for your help.
you probably have to write your own new/delete operator. That should be easy, because the only thing they have to do es to add/substract sizeof(operand_to_new/delete) to some global value and then execute standard new/delete.
I never tried this so it could be wrong
This will get the usage only for the dynamic memory. However, I want the usage for the whole program. Thanks for trying to help though.
Linux maintains a lot of live information in "/var/proc"
IIRC, each process has it's process ID in there somewhere, and within that may exist the information you're after.