From patchwork Thu May 22 01:02:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: localrepo: prevent leak of transaction object (issue4258) From: Gregory Szorc X-Patchwork-Id: 4847 Message-Id: <86829970c3fbf3134560.1400720578@vm-ubuntu-main.gateway.sonic.net> To: mercurial-devel@selenic.com Date: Wed, 21 May 2014 18:02:58 -0700 # HG changeset patch # User Gregory Szorc # Date 1400720555 25200 # Wed May 21 18:02:35 2014 -0700 # Node ID 86829970c3fbf3134560a143f74444066d2e9623 # Parent 9fb6f328576ac4e38f4e5071c4d669a6ceb3a76e localrepo: prevent leak of transaction object (issue4258) The onclose() closure added in cd443c7589cc held a regular reference to the transaction object. This was causing the transaction to not gc and a leak to occur. The closure now holds a reference to the weakref instance and the leak goes away. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -860,9 +860,9 @@ class localrepository(object): _("abandoned transaction found"), hint=_("run 'hg recover' to clean up transaction")) def onclose(): - self.store.write(tr) + self.store.write(self._transref()) self._writejournal(desc) renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()] rp = report and report or self.ui.warn