Valgrind输出中的错误摘要? [英] Error summary in Valgrind output?

查看:245
本文介绍了Valgrind输出中的错误摘要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过一些关于valgrind的帖子,但是没有一个帖子可以帮助我理解valgrind输出的解释. 我用valgrind运行了两个程序(两个都有内存泄漏)

I have seen some of the post regarding valgrind but not single post helped me in understanding interpretation of valgrind output. I ran two programs with valgrind (Both having memory leaks)

测试1的样本输出

==20422== LEAK SUMMARY:
==20422== definitely lost: 448 bytes in 3 blocks
==20422== indirectly lost: 786,460 bytes in 1 blocks
==20422== possibly lost: 1,576,052 bytes in 46 blocks
==20422== still reachable: 1,077,107 bytes in 2,333 blocks
==20422== suppressed: 0 bytes in 0 blocks
==20422== Rerun with --leak-check=full to see details of leaked memory
==20422==
==20422== For counts of detected and suppressed errors, rerun with: -v
==20422== ERROR SUMMARY: 98307 errors from 5 contexts (suppressed: 2 from 2)
Killed

测试2的输出

==20875== HEAP SUMMARY:
==20875== in use at exit: 1,059,198 bytes in 2,047 blocks
==20875== total heap usage: 3,019 allocs, 972 frees, 4,496,090 bytes allocated
==20875==
==20875== LEAK SUMMARY:
==20875== definitely lost: 328 bytes in 2 blocks
==20875== indirectly lost: 0 bytes in 0 blocks
==20875== possibly lost: 1,600 bytes in 5 blocks
==20875== still reachable: 1,057,270 bytes in 2,040 blocks
==20875== suppressed: 0 bytes in 0 blocks
==20875== Rerun with --leak-check=full to see details of leaked memory
==20875==
==20875== For counts of detected and suppressed errors, rerun with: -v
==20875== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

如果您查看错误摘要,则一个输出表明存在错误,而另一个输出表明没有错误(最终都出现泄漏)

If you look at the error summary, One output says there are errors and other says there are no errors (eventually both have leaks)

我的问题是--valgrind中什么算作错误? (valgrind手册没有帮助我)

My question is - - what is counted as error in valgrind? (valgrind manual didn't helped me)

推荐答案

内存泄漏不被视为错误,它们不会影响程序的逻辑.

Memory leaks are not considered errors, they don't effect the logic of the program.

错误是诸如无效的读写之类的事情.

Errors are things such as invalid reads and writes.

由于评论的结果而更新:测试1中的无效读写是针对5个不同的内存区域的,它们被访问了98307次.

Updated as result of comment: The invalid reads and writes in test 1 are for 5 different areas of memory which are accessed 98307 times.

从泄漏的角度看,测试1中的大量间接损失可能表明存在一个链接的数据结构,其中只有根已被删除.

Looking at the leaks, the large indirect losses in test 1 may indicated a linked data structure where only the root has been deleted.

测试2中的泄漏不太严重.正如valgrind建议使用--leak-check = full重新运行,该代码应指示引起问题的代码段.

The leaks in test 2 aren't too bad. As valgrind suggests rerun with --leak-check=full which should indicate which bit of code is causing the problem.

有关错误的完整说明,请参见此处

A full explanation of the errors can be found here

这篇关于Valgrind输出中的错误摘要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆