Fix transaction memory leak issue