Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory Allocation Profiling in C++

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.

like image 625
amit kumar Avatar asked Mar 31 '09 05:03

amit kumar


People also ask

What is allocation profiling?

The allocation profiler combines the detailed snapshot information of the heap profiler with the incremental updating and tracking of the Timeline panel. Similar to these tools, tracking objects' heap allocation involves starting a recording, performing a sequence of actions, then stop the recording for analysis.

What is a memory profile?

Memory profiling enables you to understand the memory allocation and garbage collection behavior of your applications over time. It helps you identify method calls in the context within which most memory was allocated and combine this information with the number of allocated objects.

What is heap profiling?

This is the heap profiler we use at Google, to explore how C++ programs manage memory. This facility can be useful for. Figuring out what is in the program heap at any given time. Locating memory leaks. Finding places that do a lot of allocation.


1 Answers

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.

like image 103
javier-sanz Avatar answered Oct 06 '22 08:10

javier-sanz