From a5ab2db75003a6e626de7f09d7c82510feb62c69 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Fri, 5 Jul 2013 12:57:03 -0400 Subject: [PATCH] Clear local variables in IOLoop to allow GC before we start polling. Closes #836. --- tornado/ioloop.py | 4 ++++ 1 file changed, 4 insertions(+) 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) -- 2.47.2