how to get Heap size of a program

前端 未结 6 616
太阳男子
太阳男子 2020-12-18 23:07

How to find heap memory size of a c++ program under linux platform ?I need heap memory space before the usage of new or malloc and also after that.can anyone help?

6条回答
  •  执笔经年
    2020-12-19 00:02

    You can also add heap tracking to your own programs by overloading the new and delete operators. In a game engine I am working on, I have all memory allocation going through special functions, which attach each allocation to a particular heap tracker object. This way, at any given moment, I can pull up a report and see how much memory is being taken up by entities, actors, Lua scripts, etc.

    It's not as thorough as using an external profiler (particularly when outside libraries handle their own memory management), but it is very nice for seeing exactly what memory you were responsible for.

    sample of my memory tables

提交回复
热议问题