2014-03-19 48 views
0

如果我運行valgrindValgrind的與選項

valgrind --show-reachable=yes /home/costa/Desktop/zadacha_2_7/main.c 

它說,我有依舊可達,讓我明白,這意味着有一些記憶,這是不釋放。

這裏是valgrind的輸出:

==2841== Memcheck, a memory error detector 
==2841== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. 
==2841== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info 
==2841== Command: /home/costa/Desktop/zadacha_2_7/main.c 
==2841== /home/costa/Desktop/zadacha_2_7/main.c: 5: 
     /home/costa/Desktop/zadacha_2_7/main.c: Syntax error: "(" unexpected 
==2841== 
==2841== HEAP SUMMARY: 
==2841==  in use at exit: 1,084 bytes in 68 blocks 
==2841== total heap usage: 70 allocs, 2 frees, 2,100 bytes allocated 
==2841== 
==2841== LEAK SUMMARY: 
==2841== definitely lost: 0 bytes in 0 blocks 
==2841== indirectly lost: 0 bytes in 0 blocks 
==2841==  possibly lost: 0 bytes in 0 blocks 
==2841== still reachable: 1,084 bytes in 68 blocks 
==2841==   suppressed: 0 bytes in 0 blocks 
==2841== Rerun with --leak-check=full to see details of leaked memory 
==2841== 
==2841== For counts of detected and suppressed errors, rerun with: -v 
==2841== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) 

所以,我想看到這些到達塊(未顯示),我該怎麼辦呢?

我不明白,爲什麼valgrind顯示關於這些塊的任何東西與選項--show-reachable=yes

+2

'valgrind'應在可執行運行。你甚至有編譯錯誤。修復然後,建立你的應用程序,然後在可執行文件上運行'valgrind'。另外,_still reachable_並不是什麼大不了的事情。 –

+0

@KirilKirov,我沒有得到它,編譯錯誤在哪裏?錯誤摘要中有0個。現在我同時運行一個程序和valgrind,但沒有結果(難道你不能更詳細地解釋我嗎?謝謝你的回答 –

+2

在彙總部分之前,有'語法錯誤:'(「unexpected」 。因此,在'valgrind'之前,編譯程序(使用'gcc'或其他)並運行它以查看它是否工作。然後,在完成之後,再次運行'valgrind',而不是指定'xxxxx/main .c'(s參數傳遞給vagrind),添加構建的可執行文件。 –

回答

1

比照Valgrind的輸出複製在這裏:

==2841== Rerun with --leak-check=full to see details of leaked memory