1

書いているいくつかの C コードをテストしていたところ、多くのメモリ リークがあることがわかったので、それらがどこから発生しているのかを確認したかったのです。私が持っていたすべてのコードは次のとおりです。

int main() {
    return 0;
}

何もしない単純なメインだけで、これらすべてのメモリリークが発生しました。

==38882== HEAP SUMMARY:
==38882==     in use at exit: 58,678 bytes in 363 blocks
==38882==   total heap usage: 514 allocs, 151 frees, 62,544 bytes allocated
==38882== 
==38882== LEAK SUMMARY:
==38882==    definitely lost: 8,624 bytes in 14 blocks
==38882==    indirectly lost: 1,168 bytes in 5 blocks
==38882==      possibly lost: 4,925 bytes in 68 blocks
==38882==    still reachable: 43,961 bytes in 276 blocks
==38882==         suppressed: 0 bytes in 0 blocks
==38882== Rerun with --leak-check=full to see details of leaked memory
==38882== 
==38882== For counts of detected and suppressed errors, rerun with: -v
==38882== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

このコードを大学のコンピューターで実行すると、メモリ リークは発生しません。ローカル マシンにこれほど多くのメモリ リークを引き起こしているものはありますか?

4

2 に答える 2

0

Mac でも同じエラーが発生します。これは、valgrind の問題か、(より可能性が高い) Mac のライブラリの問題です。Linux でのみ valgrind を使用することをお勧めします。

于 2013-04-12T23:01:02.073 に答える