code which concur the memory leaks in smart way