valgrind ./program
Valgrind
-
Valgrind is a tool that can help us track down invalid memory accesses and memory leaks in our programs. It keeps track of memory reads and writes in programs, as well as making sure that all dynamically allocated memory is freed.
-
To run valgrind, execute
followed by any command-line arguments you want to pass to your program.
-
Additionally, you can specify
--leak-check=full
to get details for each definitely lost or possibly lost block, including where it was allocated.