<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff size=2>Also 
take a look at last two months of the mailing list and you should find some 
answers on&nbsp;how to run scripts without leaking memory.</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff size=2>There 
are some problems with memory usage by IronPython, but developers are doing a 
very good job to fix those problems.</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff size=2>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.</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2>Thanks</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2>Andrew</FONT></SPAN></DIV>
<DIV><SPAN class=710215817-09012006><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  users-bounces@lists.ironpython.com 
  [mailto:users-bounces@lists.ironpython.com]<B>On Behalf Of </B>Bernard 
  Graham<BR><B>Sent:</B> Saturday, January 07, 2006 10:52 AM<BR><B>To:</B> 
  users@lists.ironpython.com<BR><B>Subject:</B> [IronPython] Python Memory 
  Usage<BR><BR></FONT></DIV>
  <DIV>Hi there.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>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).</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Now the scripts are executed and run very frequently (like when timers 
  are executed, or when players type commands, etc).</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>The problem I have is that after about an hour of serving, my windows 
  system goes out of virtual memory.&nbsp; When I remove the references to 
  IronPython and don't execute any scripts, the memory stays stable.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>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.</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>Here is the code I use to run a script (passed as a string to the c# 
  method):<BR>&nbsp;</DIV>
  <DIV><FONT size=2>
  <P><FONT face="courier new,monospace">pythonEngine = </FONT></P></FONT><FONT 
  face="courier new,monospace"><FONT color=#0000ff size=2>new</FONT><FONT 
  size=2> </FONT><FONT color=#008080 size=2>PythonEngine</FONT> </FONT><FONT 
  size=2><FONT face="courier new,monospace">();<BR></FONT></FONT><FONT 
  face="courier new,monospace"><FONT color=#0000ff size=2>if</FONT><FONT size=2> 
  (parameters != </FONT><FONT color=#0000ff size=2>null</FONT></FONT><FONT 
  size=2><FONT face="courier new,monospace">)<BR></FONT><FONT 
  face="courier new,monospace">{<BR></FONT></FONT><FONT color=#008000 
  size=2><FONT face="courier new,monospace">&nbsp; //Pass "parameters" to the 
  script that will be executed <BR></FONT></FONT><FONT 
  face="courier new,monospace"><FONT color=#0000ff size=2>&nbsp; 
  foreach</FONT><FONT size=2> (</FONT><FONT color=#008080 
  size=2>PythonParameter</FONT><FONT size=2> pp </FONT><FONT color=#0000ff 
  size=2>in</FONT></FONT><FONT size=2><FONT face="courier new,monospace"> 
  parameters)<BR></FONT><FONT face="courier new,monospace">&nbsp; 
  {<BR></FONT><FONT face="courier new,monospace">&nbsp;&nbsp;&nbsp; 
  pythonEngine.SetVariable(pp.Name, pp.Value); </FONT></FONT><FONT color=#008000 
  size=2><FONT face="courier new,monospace">//Variable name/variable 
  value<BR></FONT></FONT><FONT size=2><FONT face="courier new,monospace">&nbsp; 
  }<BR></FONT><FONT face="courier new,monospace">}<BR></FONT><FONT 
  face="courier new,monospace">pythonEngine.Execute(pythonScript);</FONT> 
  <P>This is executed everytime any script must be executed.</P>
  <P>Please let me know if you can spot anything wrong with this...</P>
  <P>Regards,</P>
  <P>Bernard</P></FONT></DIV></BLOCKQUOTE></BODY></HTML>