What is the best way to check for memory leaks in

2019-01-19 00:43发布

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

5条回答
Lonely孤独者°
2楼-- · 2019-01-19 01:25

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.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-19 01:26

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.

查看更多
4楼-- · 2019-01-19 01:27

On Windows:

Compuware BoundChecker (bit costly but very nice)

Visual LeakDetector (free, google it)

On Linux/Unix:

Purify

查看更多
相关推荐>>
5楼-- · 2019-01-19 01:37

You can read good article about memory leaks on Wikipedia: http://en.wikipedia.org/wiki/Memory_leak

This page also has the good links to other articles and even programms that will help you a lot.

查看更多
甜甜的少女心
6楼-- · 2019-01-19 01:41

If you use Anjuta,you can use valgrind module.

查看更多
登录 后发表回答