简体   繁体   English

Valgrind的摘要:输出中是否存在内存泄漏?

[英]Summary of Valgrind : is there a memory leak in the output?

My program is written in C++, i ran valgrind to check for memory issues. 我的程序是用C ++编写的,我运行valgrind来检查内存问题。 However, i am not quite sure, what happens when you have more allocated memory than freed, yet the summary says there is no leak. 但是,我不太确定,当您分配的内存多于释放的内存时,会发生什么,但摘要指出没有泄漏。 Here is the output of the following command: 这是以下命令的输出:

valgrind --leak-check=full  ./myprogram

The output (Centos 6): 输出(Centos 6):

==28196== 
==28196== HEAP SUMMARY:
==28196==     in use at exit: 66,748 bytes in 1 blocks
==28196==   total heap usage: 7 allocs, 6 frees, 67,964 bytes allocated
==28196== 
==28196== LEAK SUMMARY:
==28196==    definitely lost: 0 bytes in 0 blocks
==28196==    indirectly lost: 0 bytes in 0 blocks
==28196==      possibly lost: 0 bytes in 0 blocks
==28196==    still reachable: 66,748 bytes in 1 blocks
==28196==         suppressed: 0 bytes in 0 blocks
==28196== Reachable blocks (those to which a pointer was found) are not shown.
==28196== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==28196== 
==28196== For counts of detected and suppressed errors, rerun with: -v
==28196== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
Profiling timer expired

Can somebody elaborate on the suppression issue? 有人可以详细介绍抑制问题吗?

Thank you 谢谢

Still reachable means that you have pointers to the memory but you didn't free it before shutdown. 仍然可以访问意味着您有指向内存的指针,但是在关机之前没有释放它。 In most cases, this means that there isn't a problematic memory leak because most of the time this is a data structure you filled in but didn't free before shutdown. 在大多数情况下,这意味着不会有问题的内存泄漏,因为在大多数情况下,这是您填充的数据结构,但在关机前并未释放。

This question Still Reachable Leak detected by Valgrind has more explanation in the top answer. Valgrind检测到的这个“ 仍然可达到的泄漏”问题在最高答案中有更多解释。

EDIT: To elaborate on suppression, valgrind can read files to suppress certain errors, and this note that is suppressed 2 from 2 means that 2 errors from the list of suppressed errors were also found. 编辑:详细介绍抑制,valgrind可以读取文件以抑制某些错误,并且此注释从2抑制2表示从抑制的错误列表中也发现2个错误。 Errors are often suppressed because they are in a third party library or are known to not cause issues. 错误通常会被抑制,因为它们在第三方库中或已知不会引起问题。 For more information about suppressing errors, please check valgrind's explanation of error suppression . 有关抑制错误的更多信息,请查看valgrind对错误抑制的说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM