If we would like to check for memory leaks in a C++ program, we can overload the new
and delete
operators to keep track of the memory that was allocate
Valgrind is what you need.
I remember reading first chapter of Algorithms in a Nutshell which talked about this although it didn't include code. Just added in case you find it interesting.
since there is no operator overloading in c can we over-write malloc function point to intercept calls to malloc and track memory allocation
Actually, you can. GIve LD_PRELOAD a read.