Valgrind tool is used to for memory
leaks, uninitialized memory, reading or writing to memory that has
been freed, invalid access to memory(boundary conditions for the
dynamic arrays), mismatched use of malloc/new/new[] with
free/delete/delete[] , double free/delete.
How to use Valgrind:
>Compile the program with -g option
(this option will add debugging symbols), so that we can see line
numbers of the program when debugging
$ g++ -o test -g test.cpp