I need a memory profiler to know the memory usage for each function. I know valgrind (Massif) but it doesn't give me information about specific functions (at least, I don't know how to do it with massif)
Do you know any tool for this purpose in Linux?
Thanks!
Memory Profiling uses Source Code Insertion Technology for C and C++. Because of the different technologies involved, Memory Profiling for Java is covered in a separate section. Memory Profiling for C and C++ supports the following languages: C: ANSI 89, ANSI 99, or K&R C. C++: ISO/IEC 14882:1998.
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.
The most common type of profiler is the sampling profiler. They work by interrupting the application under test periodically in proportion to the consumption of the resource we're interested in. While the program is interrupted the profiler grabs a snapshot of its current state, which includes where in the code it is.
Massif
does show you which functions were responsible for the memory usage, as long as you've compiled your program with debugging info (-g
). It will even show you the line number.
This information is given as a call tree in each detailed snapshot under the graph in the ms_print
output. The frequency of detailed snapshots can be controlled with the --detailed-freq
option to massif. See Section 9.2.6 of the Massif manual for details on reading the detailed snapshot information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With