valgrind - it is a flexible program for debugging and profiling programs

To debug and profiling a sample program
$ valgrind ./sample_program

To detect memory leaks 
$ valgrind --leak-check=full --show-leak-kinds=all ./sample_program

To get more detailed memory-leak output
$ valgrind --leak-check=full ./sample_program



regards,
T.Dhanasekar