Search code examples
c++memoryclass-instance-variables

How can I statistic instance numbers of each class and the memory they consumed in the peak time in native C++ project


My compiler project has a serious memory-consuming. So I want to find a method that can find out which class is the worst one. It should give me something like bellow:

--------------------------------------------------------------------
Class name, Instance count, Peak memory consumed

Circle, 223, 2230 k

Rectangle, 124, 3220 k

Line, 22322, 222322 k

....., ...,   .... .

I have searched for a long time on the web but no result so far. :(

I have tried Devpartner tools. It can't deal with native C++ as I know. Does that because of I don't know how to use it?

Do you have any suggestion?


Solution

  • Ofcourse I hope you are talking of Dynamically allocated memory.

    You should use memory profiling tools.
    If not you should overload the new anddelete` operators for your own class and implement the memory count mechanism in the same.