]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Clear local variables in IOLoop to allow GC before we start polling.
authorBen Darnell <ben@bendarnell.com>
Fri, 5 Jul 2013 16:57:03 +0000 (12:57 -0400)
committerBen Darnell <ben@bendarnell.com>
Fri, 5 Jul 2013 16:57:03 +0000 (12:57 -0400)
Closes #836.

tornado/ioloop.py

index 5f37032f3757ae4d2df5bbaacc5c956f9cb9c8d7..5b0d4ee73b7be03b0d98d53d6147bcb6162d392e 100644 (file)
@@ -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)