简体   繁体   中英

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. 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):

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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