更新时间:2022-02-26 21:44:24
valgrind
用于 Unix 的分析器提供了不错的泄漏检测.
The valgrind
profiler for Unix offers a decent leak detection.
然而,这只是成功方法的一部分.另一部分是防止(即最小化)显式内存处理.智能指针和分配器可以在很大程度上帮助防止内存泄漏.此外,确实使用 STL 类:std::list
已经提供了无泄漏链表实现.
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
.