/******************************************************************** * memleak.c * * Example program to use Valgrind's memcheck tool to identify memory * that was allocated and failed to be returned to the heap. * * Execute using the following commands: * $ module load valgrind * $ gcc -g memleak.c * $ valgrind --tool=memcheck --leak-check=full memleak.c * * Copyright Research Computing Center, University of Chicago * Author: Douglas Rudd - 4/19/2013 *******************************************************************/ #include #include #include int main( int argc, char *argv[] ) { int i; int *buffer; for ( i = 0; i < 10; i++ ) { buffer = malloc(20*sizeof(int)); memset( buffer, 0, 20*sizeof(int) ); } return 0; }