查内存泄漏备忘

文章

http://yalung929.blog.163.com/blog/static/203898225201212981731971/
http://huqunxing.site/2017/03/31/linux内存占用分析/
http://blog.yufeng.info/archives/2456
https://jameshunt.us/writings/smaps.html

参考文献:
[1]: https://www.facebook.com/notes/facebook-engineering/scalable-memory-allocation-using-jemalloc/480222803919 "Scalable memory allocation using jemalloc"
[2]: https://www.youtube.com/watch?v=RcWp5vwGlYU "Tick Tock, malloc Needs a Clock(Video)"
[3]: http://tinylab.org/the-builtin-heap-profiling-of-jemalloc/ "jemalloc 之堆占用剖析·内部实现"
[4]: http://tinylab.org/memory-allocation-mystery-·-jemalloc-a/ "内存分配奥义·jemalloc(一)"
[5]: http://tinylab.org/memory-allocation-mystery-·-jemalloc-b/ "内存分配奥义·jemalloc(二)"
[6]: http://www.360doc.com/content/13/0915/09/8363527_314549128.shtml "ptmalloc,tcmalloc和jemalloc内存分配策略研究"
[7]: https://www.cnblogs.com/gaoxing/p/4253833.html "jemalloc和内存管里"
[8]: https://blog.csdn.net/initphp/article/details/50833036 "内存管理器ptmalloc"
[9]: https://blog.iret.xyz/article.aspx/linux_heapoverflow_enterance "ptmalloc 学习"
[10]:https://www.cnblogs.com/lookof/archive/2013/03/26/2981768.html "泄露内存释放"

[12]:https://blog.csdn.net/u012420933/article/details/16966387 sbrk和brk的区别

gperftools

安装 gperftools

https://github.com/gperftools/gperftools
编译:
执行自动生成的时候出现错误提示:

sh autogen.sh
configure.ac:163: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation

需要安装库 libtool

sudo apt-get install libtool 

编译静态库

./configure --disable-shared CXXFLAGS=-g && make

使用时加上编译选项

 -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free

查看内存工具

cat proc/$PID/maps
cat proc/$PID/smaps

posted @ 2018-02-03 00:32  tomren  阅读(240)  评论(0编辑  收藏  举报