Measure the overall memory usage of my application
I want to measure the overall memory usage of my application Qt (including memory that is not created dynamically, eg, with 'new' operator ). I wonder if there is a class or object in Qt for this type of task.
In the case of memory created dynamically, I was thinking to create two macro: one to use instead of the new operator and the other instead of delete operator, so keep track memory allocated and freed ... is this a good idea?, is there a better or simpler way to do this measurement?.
How could I measure the memory is not created dynamically?
Thanks in advance for any help and/or suggestions.
Replacing "new" and "delete" via macro doesn't work, since it only effects your own code - but most memory allocations will probably occur indirectly inside Qt classes and other libraries that you use (not to forget the Standard C library). Instead you would need to "hook":http://en.wikipedia.org/wiki/Hooking malloc() and free().
"Memory Allocation Hooks":http://www.gnu.org/software/libc/manual/html_node/Hooks-for-Malloc.html
Anyway, if you just want to see the overall memory usage of your application, a standard task manager like "htop" on Linux or "Process Explorer" on Windows will do the job! And if you want a more detailed analysis, e.g. to scan for memory leaks, use a tool like "Valgrind" (Linux) or "VLD" (Windows).