I think I have found another memory leak. When you create cycles with QObjects they aren't collected. This doesn't happen with pure python objects (as expected), but in that case I have found an strange behaviour when you set the gc.DEBUG_SAVEALL flag (that isn't PyQT related, but take that in account if you add gc debug flags). See the attached script and their logs.
Saludos, Nahuel Greco.
using_pure_python_class.log
Description: Binary data
using_qobject_class.log
Description: Binary data
#!/usr/bin/python from qt import * import sys, os, gc ######### Query Memory Usage Functions #################################### def report(s): print s sys.stdout.flush() def presentMemData(s=""): vmsize = vmrss = 0 for l in open('/proc/self/status','r').readlines(): if l.startswith('VmSize:'): vmsize = int(l.split()[1]) elif l.startswith('VmRSS:'): vmrss = int(l.split()[1]) report(s+"VmSize: %d Kb VmRss: %d Kb" % (vmsize,vmrss)) ########################################################################### TestClass = QObject ## If you uncomment the following line then the script dont leaks: #class TestClass: pass ## Warning, if you uncomment the following line, then the script will leak ## even without using the QObject class. This is because the DEBUG_SAVEALL ## setting is enabled, but is strange because with that flag, only ## unreacheable objects (that is, objects with a __del__ method, see the ## gc module documentation) are saved, and that cant be the case of the ## QObject class or the pure python one. #gc.set_debug(gc.DEBUG_LEAK | gc.DEBUG_STATS) # This is enabled by default, just in case. gc.enable() # After this setting, gc.collect() will check all the generations gc.set_threshold(1,1,1) report("Is GC enabled?: %r" % gc.isenabled()) report("Has TestClass a __del__ method? (if True, it will be marked as unreachable): %r" % hasattr(TestClass(), '__del__')) report("PY Version: "+ sys.version) report("QT Version: "+ qVersion()) report("PYQT Version: "+ PYQT_VERSION_STR) report("SIP Version: "+ os.popen('sip -V').read()) presentMemData() for i in xrange(100): for j in xrange(50): a = TestClass() b = TestClass() a.payload = ("%r"%a)*100 a.win = b b.win = a # uncomment the following line when using QObject to disable the leak #b.win = None a = None # redundant b = None # redundant gc.collect() presentMemData("%03d " % i)
_______________________________________________ PyKDE mailing list PyKDE@mats.imk.fraunhofer.de http://mats.imk.fraunhofer.de/mailman/listinfo/pykde