[IronPython] Embedded IP eating memory
Rodolfo Conde
rodolfoconde at saitosoft.com
Mon Aug 14 21:49:37 CEST 2006
i did as you said, the problem didnt go, but the memory consumtion was only 150K. then what i tried was to make only one static object of the class inside the module CMOpFuncionalidad.py, and put it right there, so my while-cycle script now is:
import sys
try:
i = sys.path.index("scripts")
except:
sys.path.append("scripts")
import CMOpFuncionalidad
try:
#pyop = CMOpFuncionalidad.PyOperador()
pyop = CMOpFuncionalidad.pyop
if not pyop.variablesInicializadas:
pyop.colocaOpBD(cmop, dba, connID)
pyop.atiendeCM()
#pyop.liberaRecursos()
pyop = None
except:
if pyop != None:
#pyop.liberaRecursos()
pyop = None
raise
I.e. i initialize the object and the internal variables only once, and now it only consumes 150 bytes each time. It seems IP beta was not able to GC the pyop object and the related variables, even no references were left for it (and the internal variables were cleaned inside the method pyop.liberaRecursos(). Now i dont know where the 150 bytes are being left, perhaps local variables memory isnt cleaned up neither (just a wild guess here :) ) ??
Cheers...
----- Original Message -----
From: Dino Viehland
To: Discussion of IronPython
Sent: Friday, August 11, 2006 4:25 PM
Subject: Re: [IronPython] Embedded IP eating memory
The real problem is that by directly interfacing w/ the Engine APIs you're not doing a simple import. There is actually an Import API but that's only going to import the code into the "default module" and not provide you w/ a convenient way to execute it.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Rodolfo Conde
Sent: Friday, August 11, 2006 4:50 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Embedded IP eating memory
PS. The module the script loads with import (CMOpFuncionalidad.py) has 15 global-module variables, but with import the module loads only once...doesnt it ??
Cheers...
----- Original Message -----
From: Dino Viehland
To: Discussion of IronPython
Sent: Friday, August 11, 2006 1:48 PM
Subject: Re: [IronPython] Embedded IP eating memory
How are you executing the script file? If you're creating a new optimized module each time we won't be able to collection the optimized module code. If on the other hand you're just compiling it as a helper method then when it's done running we can collect the code.
In pre-RC1 we had a leak where creating a new PythonEngine would result in a leak of a SystemState and ClrModule which were being hung onto by an event rooted in the app domain. So if you're re-creating the engine each time you might be seeing that. Also, now that I've mentioned events, you might want to check your own C# code if you're using events: It's easy to forget to unhook one and leak memory because the event handler stays alive forever.
If none of those turn out to be the problem an option here would be to download the free CLR Profiler and look at the object type that is consuming the increased memory. It'll give you a nice graphical display w/ a block view of what's referencing what.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Rodolfo Conde
Sent: Friday, August 11, 2006 12:58 PM
To: Discussion of IronPython
Subject: [IronPython] Embedded IP eating memory
Hi....
I have an IP-Embedded C# application (IP version IronPython 1.0.60523 (Beta) on .NET 2.0.50727.42, Yeah i know, im out of date, but i havent make the change to latest version because i saw there were some API changes :) ), i create one PyEngine, set some global variables and inside a while block i execute this little script every time:
import sys
try:
i = sys.path.index("scripts")
except:
sys.path.append("scripts")
import CMOpFuncionalidad
try:
pyop = CMOpFuncionalidad.PyOperador(cmop, dba, connID)
pyop.atiendeCM()
pyop.liberaRecursosBD()
pyop = None
except:
pyop.liberaRecursosBD()
pyop = None
raise
The module CMOpFuncionaliad is an IPython script i wrote, it contains a class definition. Inside the scripts i use components defined in some assemblies i made (these are already loaded into the CLR). The problem is, after the Engine takes the usual 12M+- of memory it needs, every time the script executes it consumes 2M more, i dont have a clue why is this...Does this version of IP have memory problems ? Or what else could be ?? If you need to see CMOpFuncionalidad.py let me know and ill send it....
Thanks for your help....
Greetings...
__________ Información de NOD32, revisión 1.1703 (20060811) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
----------------------------------------------------------------------------
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
__________ Información de NOD32, revisión 1.1703 (20060811) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
__________ Información de NOD32, revisión 1.1703 (20060811) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
------------------------------------------------------------------------------
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
__________ Informacisn de NOD32, revisisn 1.1703 (20060811) __________
Este mensaje ha sido analizado con NOD32 antivirus system
http://www.nod32.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060814/c83c6a26/attachment.html>
More information about the Ironpython-users
mailing list