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%. :-(
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 @@
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 */