[Ironpython-users] Some questions about gc and finalizers
Stefan.Richthofer at gmx.de
Wed Sep 17 15:18:39 CEST 2014
Dear IronPython community,
I recently worked on Jython issue 1057 (http://bugs.jython.org/issue1057) and also improved the current solution of http://bugs.jython.org/issue1634167 a bit. For these issues, it is very hard for Jython to emulate CPython behavior due to the fundamentally different GC implementation, so I suspected, IronPython might have similar problems and wondered how they are solved here.
Since I never used IronPython or .net, I would appreciate answers on a rather abstract level and apologize that I have no ambition to look into the source myself. I'm just hoping to find someone (optimally a core-dev), who can simply answer it and is maybe open for a discussion of solutions.
My questions are:
- does IronPython support acquired finalizers?
print "A finalized"
a1 = A()
A.__del__ = A__del__
a1 = None
Would it output "A finalized" or not?
In Jython this won't work so easy, because Jython avoids to overwrite the finalize method for all instances for its expensiveness. So only instances known to need finalization on creation time will be finalized. AfaIk, finalizers in .net are as expensive as in Java, so how would this work in IronPython?
- how complete is the support of the gc module?
In Jython the support is rather poor; most methods are just implemented as stubs, i.e. one-liners as
throw Py.NotImplementedError("not applicable to Java GC")
gc.collect usually returns the number of collected objects, but Jython just calls java.lang.System.gc() and returns None. I believe, tracking the number of collected objects would be possible, but very expensive, so this maybe could be added as a start-up-flag feature for debugging. How far does IronPython support this currently?
Thanks in advance!
More information about the Ironpython-users