Need a tool to detect memory leaks in C code

霸气de小男生 提交于 2019-12-21 05:27:12

问题


Is there a good application (that has some kind of gui) for testing memory leaks in c code. I would really like to test my assignment/programme but being very new to this, i struggle with using the terminal to do things, especially using gdb for debugging (to me it feels like a blast from the past, where i could be using some visual debugger).

Thanks for the help

edit: platform doesn't matter - i am running everything ;)


回答1:


Depending on the platform (you don't mention it) Valgrind is fantastic on Linux systems. It has no GUI, but doesn't need one.

Just run valgrind <path to your application + arguments> and it will run your application and spit out any errors during memory operations.

Add the --leak-check=full and --show-reachable=yes options after valgrind to get stack-traces of where your memory leaks originate.




回答2:


Purify is a great application for this.




回答3:


There's a gui for analyzing valgrind results: http://alleyoop.sourceforge.net/. Besides, there's (non-free) purify which is great, and i believe there's a trial. It has a GUI.





回答4:


On Windows, HeapMon may be of some interest, although it does not explicitly tell you where are your leaks.




回答5:


valgrind is pretty good on Linux, but it only has a command line interface




回答6:


If you're using Microsoft's DevStudio then the C run-time library has plenty of memory allocation tracking tools already built-in:

The Debug Heap

_CrtSetDbgFlag

It amazes me how few programmers seem to be aware of these tools!



来源:https://stackoverflow.com/questions/2476150/need-a-tool-to-detect-memory-leaks-in-c-code

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