release the allocated memory in main function