Add memory leak detection code