看到我只是使用valgrind來檢測代碼中的內存泄漏。所以我用在valgrind輸出中需要幫助瞭解
valgrind -v --leak-check=full --show-reachable=yes ./my_binary
我看到下面出來,我無法理解
`==16545==
==16545== HEAP SUMMARY:
==16545== in use at exit: 20,171 bytes in 647 blocks
==16545== total heap usage: 993 allocs, 346 frees, 30,090 bytes allocated
==16545==
==16545== Searching for pointers to 647 not-freed blocks
==16545== Checked 124,548 bytes
==16545==
==16545== 1 bytes in 1 blocks are still reachable in loss record 1 of 253
==16545== at 0x400677E: malloc (vg_replace_malloc.c:195)
==16545== by 0x80AAB31: xmalloc (in /bin/bash)
==16545== by 0x80796D0: make_variable_value (in /bin/bash)
==16545== by 0x80798C8: ??? (in /bin/bash)
==16545== by 0x807BA40: initialize_shell_variables (in /bin/bash)
==16545== by 0x805E897: ??? (in /bin/bash)
==16545== by 0x805FA10: main (in /bin/bash)
==16545==
==16545== 1 bytes in 1 blocks are still reachable in loss record 2 of 253
==16545== at 0x400677E: malloc (vg_replace_malloc.c:195)
==16545== by 0x80AAB31: xmalloc (in /bin/bash)
==16545== by 0x80A578B: set_locale_var (in /bin/bash)
==16545== by 0x80A5912: set_default_lang (in /bin/bash)
==16545== by 0x805FA15: main (in /bin/bash)
==16545==
==16545== 1 bytes in 1 blocks are still reachable in loss record 3 of 253
==16545== at 0x400677E: malloc (vg_replace_malloc.c:195)
==16545== by 0x80AAB31: xmalloc (in /bin/bash)
==16545== by 0x8061B9B: ??? (in /bin/bash)
==16545== by 0x8062D95: ??? (in /bin/bash)
==16545== by 0x8065481: ??? (in /bin/bash)
==16545== by 0x806801A: yyparse (in /bin/bash)
==16545== by 0x8060580: parse_command (in /bin/bash)
==16545== by 0x806064F: read_command (in /bin/bash)
==16545== by 0x80608AE: reader_loop (in /bin/bash)
==16545== by 0x805FEFB: main (in /bin/bash)`e
我只是想明白這一點? 爲什麼這並沒有給我特定的行號在沒有釋放的ma代碼中?
或者,你是不小心valgrinding編譯的程序而不是程序本身的shell包裝? – aschepler
雅我已經做了一個shell腳本來運行ma程序 –
哦,我明白了...........非常感謝你,我使用該腳本來編譯該程序,然後我需要運行ma binarary,但我在這裏給腳本名稱...謝謝你 –