summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-01-21 21:18:36 (GMT)
committerGuido van Rossum <guido@python.org>1997-01-21 21:18:36 (GMT)
commita4240132ec0d59b5798453b4b09aff1a2840c240 (patch)
tree56e469f5d94afe7d343df9ea5a0706704a5b4f1b /Python/ceval.c
parenta04d47b319bfd6fb094d5991624550cf8d6bb30f (diff)
downloadcpython-a4240132ec0d59b5798453b4b09aff1a2840c240.zip
cpython-a4240132ec0d59b5798453b4b09aff1a2840c240.tar.gz
cpython-a4240132ec0d59b5798453b4b09aff1a2840c240.tar.bz2
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%. :-(
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c12
1 files changed, 12 insertions, 0 deletions
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 */