I remember seeing a runtime diagnostics of a program that would output top memory users in something like:
PC          Memory Allocated      Times
----------  ----------------      -----
0xd94eded0           3270656       1234
0xede33294           2313324        204
0xc343340c             23820        102
...
I know the program is written in C. The PC is the address of code which allocates memory.
I suppose someone can build a hash table to keep track of all the callers of malloc() using __builtin_return_address(). But when memory is released, free() does not tell the size of memory being freed. How could the program figure that one out?
