Fix memory leak in DG.