Can someone provide a quick top level explanation of how Valgrind works? An example: how does it know when memory is allocated and freed?
Valgrind is basically a virtual machine that executes your program. It is a virtual architecture that intercepts each call to allocate/free memory.