gpt4 book ai didi

c - 需要帮助了解 valgrind 输出

转载 作者:太空宇宙 更新时间:2023-11-04 06:07:28 25 4
gpt4 key购买 nike

看到我只是使用 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 代码中的特定行号?

最佳答案

这些错误来自 /bin/bash 而不是您自己的代码。您是否从代码中运行任何 bash 脚本? Here是对它的含义的解释。我认为您可以忽略它。

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

关于c - 需要帮助了解 valgrind 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7204421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com