From a4240132ec0d59b5798453b4b09aff1a2840c240 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 21 Jan 1997 21:18:36 +0000 Subject: Kill all local variables on function return. This closes a gigantic leak of memory and file descriptors (thanks for Roj for reporting that!). Alas, the speed goes down by 5%. :-( --- Python/ceval.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Python/ceval.c b/Python/ceval.c index 651066c..3d2375c 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1696,6 +1696,18 @@ eval_code2(co, globals, locals, why = WHY_EXCEPTION; } } + + /* Kill all local variables */ + + { + int i; + for (i = co->co_nlocals; --i >= 0; ++fastlocals) { + if (*fastlocals != NULL) { + DECREF(*fastlocals); + *fastlocals = NULL; + } + } + } /* Restore previous frame and release the current one */ -- cgit v0.12