[PATCH] Fix memory leak when using hg commands over http repositories

alexandre.fayolle at logilab.fr alexandre.fayolle at logilab.fr
Thu Sep 23 04:44:35 CDT 2010


# HG changeset patch
# User Alexandre Fayolle <alexandre.fayolle at logilab.fr>
# Date 1285234887 -7200
# Node ID b74337a1172fdfbe0dc408414bab83391bd7be03
# Parent  1e2625fe371b3120fc6692e94a8323d593906302
Fix memory leak when using hg commands over http repositories

When using hg commands over an http repository in a long running process, a
httphandler instance is leaked for each command, because of a loop
handler.parent -> OpenerDirector and OpenerDirector.handlers -> handler which
is not handled by Python's gc. Discussion on #mercurial concluded that removing
the __del__ method solved the problem.

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -484,13 +484,10 @@ class httphandler(keepalive.HTTPHandler)
 
     def _start_transaction(self, h, req):
         _generic_start_transaction(self, h, req)
         return keepalive.HTTPHandler._start_transaction(self, h, req)
 
-    def __del__(self):
-        self.close_all()
-
 if has_https:
     class BetterHTTPS(httplib.HTTPSConnection):
         send = keepalive.safesend
 
         def connect(self):


More information about the Mercurial-devel mailing list