Why so many references to global variables?
Alexander Schmolck
a.schmolck at gmx.net
Thu Jul 3 17:57:27 EDT 2003
J-P <me at home.net> writes:
> It appears that every time the interpreter tests for
> the value of 'myflag', it keeps a reference to it.
What makes you think so? This seems rather unlikely to me (not that the
references themselves should eat your memory anyway!).
Chances are, the C extension code doesn't work correctly (C extensions to
python code have to do memory management by hand; increasing and decreasing
reference counts for the python objects they deal with as appropriate; so if a
bit of code forgets to decrease the refcount, the object will stay alive
forever; my guess would be that this it what happens here). So you'll have to
debug the C code. Valgrind can be *very* useful for this purpose. If you
discover anything else that really helps for tracking down such memory leaks,
I'd sure like to know.
'as
More information about the Python-list
mailing list