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

0

valgrind faqから

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 に答える