commandline session
$gcc -g leak.c
$valgrind --tool=memcheck --leak-check=full ./a.out
==4353== Memcheck, a memory error detector
==4353== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==4353== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==4353== Command: ./a.out
==4353==
==4353==
==4353== HEAP SUMMARY:
==4353== in use at exit: 100 bytes in 1 blocks
==4353== total heap usage: 1 allocs, 0 frees, 100 bytes allocated
==4353==
==4353== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
==4353== at 0x4C2BDEB: malloc (vg_replace_malloc.c:270)
==4353== by 0x40050D: main (leak.c:4)
==4353==
==4353== LEAK SUMMARY:
==4353== definitely lost: 100 bytes in 1 blocks
==4353== indirectly lost: 0 bytes in 0 blocks
==4353== possibly lost: 0 bytes in 0 blocks
==4353== still reachable: 0 bytes in 0 blocks
==4353== suppressed: 0 bytes in 0 blocks
==4353==
==4353== For counts of detected and suppressed errors, rerun with: -v
==4353== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
$cat leak.c
#include
int main()
{
char *x = (char*) malloc(100); //Mem Leak!
return 0;
}
$