Linux中内存泄漏检查工具的问题
1)是否还有名为Boehmgc
的内存泄漏工具?该工具与其他工具相比如何?
2) 我使用过 LeakTracer、mudflap 和 Valgrind。但不幸的是LeakTracer有内存占用的缺点(在启动时池化大量内存然后分配它),那么有什么替代方案呢?
1) Is there also any memory leak tool called Boehmgc
? How is that tool compared to others?
2) I have used LeakTracer
, mudflap
and Valgrind
. But unfortunately LeakTracer has the disadvantage of memory hogging (pooling a lot of memory at start and then allocating it), so what are the alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Boehm GC是一个垃圾收集器,类似于Java中的垃圾收集。您提到的其他工具旨在警告您有关泄漏的信息,以便您可以采取纠正措施。垃圾收集旨在在程序运行时查找并恢复不再使用的分配。示例(来自维基百科页面):
就我个人而言,在 C 或 C++ 中使用垃圾收集有些让我感到非常不安。对于C++“智能指针”是可行的方法在我看来,在所有权不明确的情况下(尽管您可能想了解为什么在您的设计中不清楚)以及异常安全方面的帮助(例如现在是什么 )
已弃用
std::auto_ptr
的设计目的 您可以添加泄漏检测器:到您的 Linux 列表。
相关内存检查工具,但不泄漏:
Boehm GC is a garbage collector, similar to the garbage collection in Java. The other tools you mention are designed to warn you about leaks, such that you can take corrective action. Garbage collection is designed to find and recover no-longer used allocations, as the program runs. Example (from wikipedia page):
Personally there's something about using garbage collection in C or C++ that makes me quite uneasy. For C++ "Smart pointers" are the way to go in my opinion in scenarios where ownership is unclear (although you might want to have a thing about why it's unclear in your design) and for help with exception safety (E.g. what the now deprecated
std::auto_ptr
was designed for)As for the leak detectors you can add:
To your list of Linux ones.
Related memory checking tools, but not leaks: