list “cold” memory areas

怎甘沉沦 提交于 2020-01-01 09:33:08

问题


I'm trying to hunt down a very evasive bug in a server software that look like a memory leak, but memcheck didn't help at all. My guess is that the memory that has been instantiated and never removed is indeed not leaked, so there is a reference to it, but is now useless for the program and should be removed. Is there a tool that can count accesses, not references, in memory, and so give a evaluation of the effective usage of objects in heap?


回答1:


I ended up with implementing my own tool. My approach was slightly different from what I intended: I wrote a malloc hooking library. It hooks malloc, realloc and free, and maintains a list of living malloc'd memory blocks. Whenever you send a SIGUSR1 to your application, it dumps its info in a file, and evaluate it as a Mathematica expression. The Mathematica notebook finally provide some very useful graphs: top scored instantiations by call stack, and a complete overview of calls to malloc. With these tools, I just had to hover my mouse on the fattest and most distant from the center green dot of the second graph, and, voilà, I have the address that instantiates loads of not leaked but useless memory.

P.S. The circular calls that you can see in the second graph are definitely a bug in libc's backtrace().




回答2:


Probably this tool (Visual Leak Detector) will help you. It's free.

http://vld.codeplex.com/



来源:https://stackoverflow.com/questions/8637866/list-cold-memory-areas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!