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.
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