Can someone provide a quick top level explanation of how Valgrind works? An example: how does it know when memory is allocated and freed?
Here you can find some nice info:
Besides familiarize yourself with LD_PRELOAD.