Memory Allocation Profiling in C++

amit picture amit · Mar 31, 2009 · Viewed 34.3k times · Source

I am writing an application and am surprised to see its total memory usage is already too high. I want to profile the dynamic memory usage of my application: How many objects of each kind are there in the heap, and which functions created these objects? Also, how much memory is used by each of the object?

Is there a simple way to do this? I am working on both linux and windows, so tools of any of the platforms would suffice.

NOTE: I am not concerned with memory leaks here.

Answer

javier-sanz picture javier-sanz · Mar 31, 2009

Have you tried Valgrind? It is a profiling tool for Linux. It has a memory checker (for memory leaks and other memory problems) called Memcheck but it has also a heap profiler named Massif.