Valgrind is a debugging tool that can be used to diagnose errors regarding memory management in C programs. Valgrind can be used to detect errors like invalid pointer usage, including writing or reading past the allocated space, or making an invalid call to
free(). It can also be used for improving applications through functions that conduct memory profiling.
For more info see http://valgrind.org.