[IronPython] clr.AddReference effect how GC work ?!?!?!?

Sakesun Roykiattisak sakesun at boonthavorn.com
Thu Apr 24 05:43:19 CEST 2008


> In the original example, if you "GC.Collect()" and
> "Thread.CurrentThread.Join()" immediately after the call to
> clr.AddReference, you force finalization of this COM object and any
> remaining finalization happens normally as subsequent calls to
> GC.Collect() are made.

Yes. This works too.

I've change all my clr.AddReference(xxx) to my_addref(xxx)

def my_addref(name):
     import clr
     from System import GC
     from System.Threading import Thread
     clr.AddReference(name)
     GC.Collect()
     Thread.CurrentThread.Join(0)

Probably this is the easiest way to fix #16249



More information about the Ironpython-users mailing list