fix Trainer memory leak