I get my final "done" message with valgrind, and get this exit report:
==3434== HEAP SUMMARY:
==3434== in use at exit: 8,432 bytes in 4 blocks
==3434== total heap usage: 4,369 allocs, 8,037 frees, 377,356 bytes allocated
==3434==
==3434== LEAK SUMMARY:
==3434== definitely lost: 152 bytes in 1 blocks
==3434== indirectly lost: 0 bytes in 0 blocks
==3434== possibly lost: 0 bytes in 0 blocks
==3434== still reachable: 8,192 bytes in 2 blocks
==3434== suppressed: 88 bytes in 1 blocks
==3434== Rerun with --leak-check=full to see details of leaked memory
==3434==
==3434== For counts of detected and suppressed errors, rerun with: -v
==3434== ERROR SUMMARY: 100190 errors from 140 contexts (suppressed: 0 from 0)
But when I run it without valgrind, it segfaults immediately. Does valgrind suppress a certain kind of error that I should be looking for? I can't find any information about this online
GDB and Valgrind are great helpful tools to detect and correct segmentation fault and memory leaks.
possibly lost: heap-allocated memory that was never freed to which valgrind cannot be sure whether there is a pointer or not. still reachable: heap-allocated memory that was never freed to which the program still has a pointer at exit (typically this means a global variable points to it).
"indirectly lost" means your program is leaking memory in a pointer-based structure. (E.g. if the root node of a binary tree is "definitely lost", all the children will be "indirectly lost".) If you fix the "definitely lost" leaks, the "indirectly lost" leaks should go away.
Overview. A segmentation fault (aka segfault) is a common condition that causes programs to crash; they are often associated with a file named core . Segfaults are caused by a program trying to read or write an illegal memory location.
Valgrind runs the program in a different environment than if you run it from the shell. This can prevent some crashes when relative to memory exhaustion or array outbounding.
Correct your 140 contexts of errors and you'll be okay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With