From: Ben Darnell Date: Fri, 5 Jul 2013 16:57:03 +0000 (-0400) Subject: Clear local variables in IOLoop to allow GC before we start polling. X-Git-Tag: v3.2.0b1~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5ab2db75003a6e626de7f09d7c82510feb62c69;p=thirdparty%2Ftornado.git Clear local variables in IOLoop to allow GC before we start polling. Closes #836. --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 5f37032f3..5b0d4ee73 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -605,6 +605,9 @@ class PollIOLoop(IOLoop): self._callbacks = [] for callback in callbacks: self._run_callback(callback) + # Closures may be holding on to a lot of memory, so allow + # them to be freed before we go into our poll wait. + del callbacks if self._timeouts: now = self.time() @@ -616,6 +619,7 @@ class PollIOLoop(IOLoop): elif self._timeouts[0].deadline <= now: timeout = heapq.heappop(self._timeouts) self._run_callback(timeout.callback) + del timeout else: seconds = self._timeouts[0].deadline - now poll_timeout = min(seconds, poll_timeout)