Using the dynamic library piling method to perform library piling on the malloc calloc realloc free function can achieve memory analysis.
Assume the file is located in /home/usr/mperf
Easily compile the code using compile.sh script
cd ./code
sh compile.shAdd LD_PRELOAD = your_pth/mperf.so before run run.sh script
LD_PRELOAD=/home/usr/mperf/code/mperf.so ./run.shVisual processing can be done using the provided python script
LD_PRELOAD=/home/usr/mperf/code/mperf.so ./run.sh | python /home/usr/mperf/draw/dispatch.py
python /home/usr/mperf/draw/draw.pyAfter that can get an output like this:

ps. If do not output the function call stack information, please use ./code/mperf_less.cc instead, it will greatly reduce the running time and the size of the generated analysis file.
Library Interpositioning (CSAPP):
https://hansimov.gitbook.io/csapp/part2/ch07-linking/7.13-library-interpositioning