Added memory leak detection functionality

it works