Hi
Thanks for the reply!
I will look into the things you proposed, but just to let you all know - my project was referencing an older build IP and not the latest beta release. As soon as I realized that and changed it, the memory usage completely dropped down, event with creating a new instance of the PythonEngine.
Just for interest's sake: the reason I create a new engine is that in my application it is possible for one script to make a call back to my c# host application which might again invoke another python script. If I cache the PythonEngine, the two running scripts overrides each other's variables (since they are all in the same scope).
I will probably have to look into object pooling, as you suggested.
Thanks again!
Bernard
On 1/9/06, Andrew Pliszka <[EMAIL PROTECTED]> wrote:
Hi,I had similar problems. I think major problem that I see with your code is that you create a new PythonEngine object every time you execute new script. I suggest caching the PythonEngine object or using object pooling. I also think the setVariable might be not releasing the object.I also suggest you download .Net profiler and run your code under that profiler. Then you should be able to pinpoint what objects are consuming the memory. Knowing what objects are causing the leaks, try to find different way to implement them and test again.Also take a look at last two months of the mailing list and you should find some answers on how to run scripts without leaking memory.There are some problems with memory usage by IronPython, but developers are doing a very good job to fix those problems.I think we also need a architectural blueprint of a stable, reliable IronPython scripting host, that people could use as a guideline. I see that more and more people would like to use IronPython as a server scripting host.ThanksAndrew-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Bernard Graham
Sent: Saturday, January 07, 2006 10:52 AM
To: [email protected]
Subject: [IronPython] Python Memory UsageHi there.I am (like many) quite new to IronPython (and Python in general), but I am trying to use it as a scripting language for a MUD system I am creating (like the old text-based games, only multiplayer).Now the scripts are executed and run very frequently (like when timers are executed, or when players type commands, etc).The problem I have is that after about an hour of serving, my windows system goes out of virtual memory. When I remove the references to IronPython and don't execute any scripts, the memory stays stable.I am sure I am using the IronPython engine incorrectly, so I thought that maybe someone would be able to shed some light on this for me.Here is the code I use to run a script (passed as a string to the c# method):
pythonEngine =
new PythonEngine ();
if (parameters != null)
{
//Pass "parameters" to the script that will be executed
foreach (PythonParameter pp in parameters)
{
pythonEngine.SetVariable(pp.Name, pp.Value); //Variable name/variable value
}
}
pythonEngine.Execute(pythonScript);This is executed everytime any script must be executed.
Please let me know if you can spot anything wrong with this...
Regards,
Bernard
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
