Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a424013

Browse files
committed
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%. :-(
1 parent a04d47b commit a424013

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Python/ceval.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,18 @@ eval_code2(co, globals, locals,
16961696
why = WHY_EXCEPTION;
16971697
}
16981698
}
1699+
1700+
/* Kill all local variables */
1701+
1702+
{
1703+
int i;
1704+
for (i = co->co_nlocals; --i >= 0; ++fastlocals) {
1705+
if (*fastlocals != NULL) {
1706+
DECREF(*fastlocals);
1707+
*fastlocals = NULL;
1708+
}
1709+
}
1710+
}
16991711

17001712
/* Restore previous frame and release the current one */
17011713

0 commit comments

Comments
 (0)