[IronPython] Memory Leak in CreateScriptSource?

Christian Schmidt christian2.schmidt at gmx.de
Thu Dec 25 14:37:55 CET 2008


Hi,

the following code snippet allocates constantly more and more memory. 
Moving .Compile() outside the loop works as expected.

private static void LeakTest()
{
   var runtime = Python.CreateRuntime();
   var engine = runtime.GetEngine("py");
   var sum = 0.0;

   while (true)
   {
     var code = engine.CreateScriptSourceFromString("1.0+2.0").Compile();
     sum += code.Execute<double>();
     GC.Collect();
     GC.WaitForPendingFinalizers();
     GC.Collect();
     Console.WriteLine(sum);
   }
}

Any ideas?

Merry Christmas,

Christian



More information about the Ironpython-users mailing list