Improve memory management of CommitGraph