Linux下Valgrind的调试问题,向高手求助

jack_wq 2013-07-09 04:12:26
我在开发的过程中,发现有内存泄露(申请没有及时释放)的问题,使用valgrind工具检查发现有很多still reachable的memory,summary如下:
LEAK SUMMARY:
definitely lost: 0 bytes in 0 blocks
indirectly lost: 0 bytes in 0 blocks
possibly lost: 0 bytes in 0 blocks
still reachable: 58,576 bytes in 1,958 blocks
suppressed: 0 bytes in 0 blocks
但是没有显示堆栈信息,显示信息如下(部分)
3,552 bytes in 222 blocks are still reachable in loss record 627 of 628
at 0x4A05E1C: malloc (vg_replace_malloc.c:195)
by 0x4579EA: xmalloc (in /bin/bash)
by 0x41FA4F: ??? (in /bin/bash)
by 0x4218DB: yyparse (in /bin/bash)
by 0x41B506: parse_command (in /bin/bash)
by 0x41B5C5: read_command (in /bin/bash)
by 0x41B74D: reader_loop (in /bin/bash)
by 0x41B2A9: main (in /bin/bash)

8,192 bytes in 1 blocks are still reachable in loss record 628 of 628
at 0x4A05E1C: malloc (vg_replace_malloc.c:195)
by 0x4579EA: xmalloc (in /bin/bash)
by 0x446FDF: fd_to_buffered_stream (in /bin/bash)
by 0x447097: with_input_from_buffered_stream (in /bin/bash)
by 0x41B24B: main (in /bin/bash)

命令行参数如下:
valgrind --leak-check=full --show-reachable=yes -v --read-var-info=yes --num-callers=10 --leak-resolution=high
不知道是我的valgrind参数设置问题还是其他什么问题,如何能显示内存泄露调用的堆栈信息?请高手指教。谢谢。
分不够可以再加,这个不是问题。
...全文
257 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
pix77 2013-07-10
  • 打赏
  • 举报
回复
类似于at 0x4A05E1C: malloc (vg_replace_malloc.c:195)这样, 指出文件名行数的
jack_wq 2013-07-09
  • 打赏
  • 举报
回复
谢谢楼上的链接,我看过了。 我想知道如何找到这些still reachable的内存是在哪里申请的?从输出信息看不到的。如何能知道呢?

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧