2

我遇到了一个问题。当我用我的程序运行 valgrind 时,我得到了以下输出,这让我很困惑:

==12919== HEAP SUMMARY:
==12919==     in use at exit: 97,820 bytes in 1 blocks
==12919==   total heap usage: 17 allocs, 16 frees, 99,388 bytes allocated
==12919==
==12919== LEAK SUMMARY:
==12919==    definitely lost: 0 bytes in 0 blocks
==12919==    indirectly lost: 0 bytes in 0 blocks
==12919==      possibly lost: 0 bytes in 0 blocks
==12919==    still reachable: 97,820 bytes in 1 blocks
==12919==         suppressed: 0 bytes in 0 blocks
==12919== Reachable blocks (those to which a pointer was found) are not shown.
==12919== To see them, rerun with: --leak-check=full --show-reachable=yes
==12919==
==12919== For counts of detected and suppressed errors, rerun with: -v
==12919== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
4

2 回答 2

2

我发现它是由带有“-pg”标志的编译引起的。没有它一切都好!

于 2013-09-20T05:09:01.823 回答
0

来自valgrind 常见问题

5.2. 使用 Memcheck 的内存泄漏检测器,“肯定丢失”、“间接丢失”、“可能丢失”、“仍然可达”和“被抑制”有什么区别?

详细信息在用户手册的 Memcheck 部分。

简而言之:

"definitely lost" means your program is leaking memory -- fix those leaks!

"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.

"possibly lost" means your program is leaking memory, unless you're doing unusual things with pointers that could cause them to point into the middle of an allocated block; see the user manual for some possible causes. Use --show-possibly-lost=no if you don't want to see these reports.

"still reachable" means your program is probably ok -- it didn't free some memory it could have. This is quite common and often reasonable. Don't use --show-reachable=yes if you don't want to see these reports.

"suppressed" means that a leak error has been suppressed. There are some suppressions in the default suppression files. You can ignore suppressed errors.
于 2013-09-19T16:13:28.200 回答