1

I am using someone's code. It's a mess with a terrible coding style, weird function and variable names, and tones of macros, etc. My main concern is to find the function that loads things from disk to the memory. This function will drastically change the memory peak of the program. Now I am wondering if there is any tool that can provide me a list of functions with the memory consumption of each.

Paul R
  • 208,748
  • 37
  • 389
  • 560
user3639557
  • 4,791
  • 6
  • 30
  • 55
  • How is the memory consumption of a function defined? – rozina Apr 20 '16 at 10:47
  • A decent profiler will give you a good overview of which functions are taking CPU time and allocating memory. – Paul R Apr 20 '16 at 10:48
  • 1
    Then look at this http://stackoverflow.com/questions/1623771/valgrind-massif-tool-output-graphical-interface ? – fghj Apr 20 '16 at 10:51

2 Answers2

3

You can use valgrind tool massif.

Massif is a heap profiler. I believe it is exactly what you need!

Simply start with:

valgrind --tool=massif <your prog>
ms_print massif.out.<your pid>

Detailed example and help can be found here: http://valgrind.org/docs/manual/ms-manual.html#ms-manual.anexample

Klaus
  • 24,205
  • 7
  • 58
  • 113
1

If you are using Linux then Valgrind is tool for this.

Aivars
  • 93
  • 7