Valgrind的混乱输出显示间接丢失的内存泄漏,但是没有明确丢失或可能丢失 [英] Confusing output from Valgrind shows indirectly lost memory leaks but no definitely lost or possibly lost

查看:538
本文介绍了Valgrind的混乱输出显示间接丢失的内存泄漏,但是没有明确丢失或可能丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在macos x 10.8上运行valgrind。 Valgrind在启动时表示

 == 11312 ==警告:MacOS 10.8上的支持是实验性的, == 11312 ==警告:预期不正确的结果,断言和崩溃
== 11312 ==警告:特别是,32位程序上的Memcheck将无法
== 11312 ==警告:检测任何与堆分配的数据相关的错误。

Valgrind提供此泄漏摘要:

 漏洞摘要:
== 11312 ==绝对丢失:0块在0块
== 11312 ==间接丢失:48字节2块
== 11312 ==可能丢失:0个字节在0块
== 11312 ==仍然可达:45,857个字节在270个块
== 11312 ==被抑制:16,805个字节在87个块

根据valgrinds faq, http://valgrind.org/docs/manual/faq.html#faq.deflost ,间接丢失意味着您的程序正在泄漏内存基于指针的结构。 (例如,如果二叉树的根节点绝对丢失,所有的子节点将被间接丢失。)如果你修正绝对丢失的泄漏,间接丢失的泄漏应该消失。 >

我没有任何明确丢失的泄漏,甚至可能丢失泄漏修复。我应该解决什么?这个报告可能是一个bug,由于valgrind在10.8的实验性质?



我相信我是编译为64位程序,因为编译器是一个64位编译器。

解决方案

我觉得奇怪回答自己的问题。



是的,valgrind在mac上的报告不正确。根据valgrind on linux,所有的堆块被释放,所以没有泄漏是可能的。



我真的希望valgrind修复mac的问题,因为我主要是在mac上开发。 / p>

I am running valgrind on the macos x 10.8. Valgrind says on startup

"==11312== WARNING: Support on MacOS 10.8 is experimental and mostly broken.
==11312== WARNING: Expect incorrect results, assertions and crashes.
==11312== WARNING: In particular, Memcheck on 32-bit programs will fail to
==11312== WARNING: detect any errors associated with heap-allocated data."

Valgrind is giving this leak summary:

"LEAK SUMMARY:
==11312==    definitely lost: 0 bytes in 0 blocks
==11312==    indirectly lost: 48 bytes in 2 blocks
==11312==      possibly lost: 0 bytes in 0 blocks
==11312==    still reachable: 45,857 bytes in 270 blocks
==11312==         suppressed: 16,805 bytes in 87 blocks"

According to valgrinds faq, http://valgrind.org/docs/manual/faq.html#faq.deflost, "indirectly lost" means your program is leaking memory in a pointer-based structure. (E.g. if the root node of a binary tree is "definitely lost", all the children will be "indirectly lost".) If you fix the "definitely lost" leaks, the "indirectly lost" leaks should go away.

I dont have any definitely lost leaks or even possibly lost leaks to fix. What am I supposed to fix? Could this report be a bug due to the experimental nature of valgrind in 10.8?

I believe i am compiling this as a 64 bit program since the compiler is a 64 bit compiler.

解决方案

I feel weird answering my own question.

Yes the report by valgrind on mac is incorrect. According to valgrind on linux all heap blocks were freed so no leaks are possible.

I really hope valgrind fixes the issues with mac since I mainly am developing on mac now.

这篇关于Valgrind的混乱输出显示间接丢失的内存泄漏,但是没有明确丢失或可能丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆