
=17722= 1 bytes in 1 blocks are definitely lost in loss record 1 of 1 =17722= Searching for pointers to 1 not-freed blocks =17722= total heap usage: 1 allocs, 0 frees, 1 bytes allocated =17722= in use at exit: 1 bytes in 1 blocks $ valgrind -tool=memcheck -leak-check=full -v. valgrind_hello_badĪnd now, Valgrind reports about a memory leak of 1 byte in its output: $ gcc -Wall -gstabs valgrind_hello_bad.c -o valgrind_hello_bad Test with valgrind: $ valgrind -tool=memcheck. Compile with debug info: $ gcc -Wall -gstabs valgrind_hello_bad.c -o valgrind_hello_bad A simple way of doing so it is with a malloc in the main code: So, let's introduce a simple memory leak in our code. =17635= ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) =17624= Using Valgrind-3.7.0 and LibVEX rerun with -h for copyright info =17624= Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al. =17624= Memcheck, a memory error detector


$ gcc -Wall -gstabs valgrind_hello_good.c -o valgrind_hello_good The compilation of the source code valgrind_hello_good.c and running the image created with gccīy means of Valgrind-Memcheck, there are zero errors. This simple example has not any type of anomaly Valgrind can detect with Memcheck.

Compile with compiler: $ gcc -Wall -gstabs valgrind_hello_good.c -o valgrind_hello_good Save this code as valgrind_hello_good.c
