Hi,

    My today attempt to fight with over-memory usage in my IronPython
server application, reveal a very strange behavior of IronPython
(both 1.1 and 2.0b) I'll demonstrate with the following script: "loopit.py"


##### loopit.py ###########################

import clr
#clr.AddReference('System')

class MyObj(object):
    def __del__(self): print 'gone'

def run():
    from System.Threading import Thread
    from System import GC
    while True:
        MyObj()
        Thread.Sleep(100)
        GC.Collect()

run()

###########################################


try to run this script you'll see a stream of 'gone' print out.
However, if you uncomment the line "clr.AddReference('System')"
and rerun it again the system will simple halt, memory usage
will keep raising. Until you press Ctrl-C, then the you will
see the pending 'gone' stream out.

I've tried with

clr.AddReference('System.Data')
clr.AddReference('System.Xml')

and the behaviour is the same for any Assembly.
This is really weird. Why should clr.AddReference effect how
GC work ?

And I believe this is indeed the true source of memory problem I'm facing.

Hope someone explain me why.

Thanks
import clr
#clr.AddReference('System')

class MyObj(object):
    def __del__(self): print 'gone'

def run():
    from System.Threading import Thread
    from System import GC
    while True:
        MyObj()
        Thread.Sleep(100)
        GC.Collect()

run()
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to