Slide 38
Slide 38 text
$ valgrind --tool=memcheck ./memoryleak
==31747== Memcheck, a memory error detector
==31747== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==31747== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==31747== Command: ./memoryleak
==31747==
==31747== Invalid write of size 4
==31747== at 0x100000F4C: f (memoryleak.c:6)
==31747== by 0x100000F73: main (memoryleak.c:10)
==31747== Address 0x100ae34a8 is 0 bytes after a block of size 40 alloc'd
==31747== at 0x100008EBB: malloc (in /usr/local/Cellar/valgrind/3.11.0/lib/
valgrind/vgpreload_memcheck-amd64-darwin.so)
==31747== by 0x100000F43: f (memoryleak.c:5)
==31747== by 0x100000F73: main (memoryleak.c:10)
==31747==
==31747==
==31747== HEAP SUMMARY:
==31747== in use at exit: 35,304 bytes in 431 blocks
==31747== total heap usage: 503 allocs, 72 frees, 41,272 bytes allocated
==31747==
==31747== LEAK SUMMARY:
==31747== definitely lost: 40 bytes in 1 blocks
==31747== indirectly lost: 0 bytes in 0 blocks
==31747== possibly lost: 0 bytes in 0 blocks
==31747== still reachable: 0 bytes in 0 blocks
==31747== suppressed: 35,264 bytes in 430 blocks
==31747== Rerun with --leak-check=full to see details of leaked memory
==31747==
==31747== For counts of detected and suppressed errors, rerun with: -v
==31747== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)