需要有关 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代码中尚未释放的特定行号?
see i am just using valgrind for detecting memory leakage in my code. so i have used
valgrind -v --leak-check=full --show-reachable=yes ./my_binary
i see following out which i can not understand
`==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
i just want to understand this.?
why this does not giving me particular line no in ma code which has not freed ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这些错误来自
/bin/bash
而不是您自己的代码。您是否在代码中运行任何 bash 脚本? 这里解释了它的含义。我认为你可以忽略它。These errors come from
/bin/bash
not from your own code. Are you running any bash scripts from your code? Here is explanation of what it means. I think you can just ignore it.看起来这些地址属于您的程序代码。也许使用调试信息进行编译可以让 valgrind 看到行号。 (提示:-g 开启 gcc)
It looks like those addresses belong to your program's code. Perhaps compiling with debug information lets valgrind see line numbers. (Hint: -g switch on gcc)
您检查过 http://valgrind.org/docs/manual/快速启动.html#quick-start.intro ?那里有一个很好的文档。您在编译时不应该使用任何优化。
Have you checked http://valgrind.org/docs/manual/quick-start.html#quick-start.intro ? There is a good documentation there. You shouldn't have used any optimization while you're compiling.
如果您想检查自动工具驱动的编译的结果(它实际上在您的构建目录中创建了一个 shell 脚本),您可能想尝试以下操作:
If you want to check the result of an autotools-powered compilation (it really creates a shell script in your build dir), you might want to try this instead: