[IronPython] Is this memory leak ?

Szymon Kobalczyk s.kobalczyk at softwaremind.pl
Fri Nov 4 14:52:25 CET 2005


We just noticed a serious memory leak in our server application. It 
happens after we execute some code that uses extensively dynamic 
scripting with IronPython. After one run the allocation grows from 70MB 
to more then 500MB.

I've investigated the memory heap using WinDbg and all paths lead to the 
IronPython.Objects.Frame. All the variables that I passed to the 
PythonEngine are kept in the dictionary inside these Frames. These 
Frames in turn are kept in some static object[] array.

In attached project I run in a loop some trivial script using engine 
Execute method. You can attach to it using WinDbg and check that after 
the loop completes there are 100 instances of Frame. Here is one sample 
from the gcroot command:

0:003> !gcroot 00b37918
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Scan Thread 0 OSTHread 13dc
Scan Thread 2 OSTHread 17fc

I also tried this with the evaluate method and the effect was the same. 
Only with (my favorite) FastEval option the memory is not allocated. So 
this could mean this leak occurs during code generation.

I hope this is something that can be fixed quickly as we need to deploy 
this solution to production.

Note: I still work on .NET Beta 2 and IronPython 0.9.3. I also run the 
test on the 0.9.4 version but results were the same.

Thanks in Advance,
Szymon Kobalczyk.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: IronPythonMemory.zip
Type: application/x-zip-compressed
Size: 168866 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20051104/396bc1fb/attachment.bin>

More information about the Ironpython-users mailing list