johnbickmore / livecoding

A code reloading library for Python
https://code.google.com/archive/p/livecoding/
Other
0 stars 0 forks source link

MODE_UPDATE leaks old classes #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
MODE_UPDATE works by executing a changed script file into a custom globals
dictionary, then processing what is in there, transferring the interesting
bits over to the first loaded version of that script.

However, in my usage of it, I am seeing the classes in the changed script
file hanging around.  So if I look up all the subclasses of a given base
class, I will find any version of those subclasses which has ever existed.

This appears to be because of the circular reference between a class and
the func_globals variable on the functions defined on it.  But this does
not seem like it should be a problem.

For now, I clear the globals dictionary for a script (which is what
func_globals on every class function within that script points to) when
that script is garbage collected.  Which works as a workaround.

Original issue reported on code.google.com by richard.m.tew@gmail.com on 21 Jan 2010 at 1:59