[fix] memory leak and handle end time.