What is the best way to check for memory leaks in c++?

前端 未结 4 1733
迷失自我
迷失自我 2020-12-10 15:21

I\'m implementing a sparse matrix with linked lists and it\'s not fun to manually check for leaks, any thoughts?

相关标签:
4条回答
  • 2020-12-10 15:51

    The valgrind profiler for Unix offers a decent leak detection.

    However, this is only one part of a successful approach. The other part is to prevent (i.e. minimize) explicit memory handling. Smart pointers and allocators can help a great deal in preventing memory leaks. Also, do use the STL classes: a leak-free linked list implementation is already provided by std::list.

    0 讨论(0)
  • 2020-12-10 15:54

    If you use Anjuta,you can use valgrind module.

    0 讨论(0)
  • 2020-12-10 15:57

    On Windows:

    Compuware BoundChecker (bit costly but very nice)

    Visual LeakDetector (free, google it)

    On Linux/Unix:

    Purify

    0 讨论(0)
  • 2020-12-10 16:01

    The original version of Purify on Unix was brilliant. But the Windows version produced after Rational bought it is terrible. Flakey as hell. Avoid at all costs.

    0 讨论(0)
提交回复
热议问题