I have a program that is using a lot more memory total over its lifetime than I am expecting and I'd like to see if there's anything I can do about it.
I've used Valgrind's memcheck tool to get rid of the memory leaks, and Valgrind's massif tool to see heap snapshots. massif can tell me which lines are responsible for the largest heap blocks at a particular point in time. Since massif doesn't show anything very large, I suspect my problem is particular lines that do smaller allocations lots of times.
In case some numbers would be helpful: the program runs for about 5s, doing intensive numerical calculations. The peak memory usage is 1MB. The lifetime memory usage is 10GB. The largest single allocation is 250KB and that is done 8 times.
Therefore what I wish to see is not which lines have allocated a lot of memory at any particular point in time, but a sum over the whole lifetime of the program for each line that allocates. I feel that Valgrind should have access to that information, since it's tracking every allocation, but I don't know how to get it to tell me.
Can any one suggest either how to use Valgrind to report this information, or another tool that will do what I want?