[IronPython] Memory Leak in CreateScriptSource?

Dody Gunawinata empirebuilder at gmail.com
Fri Dec 26 07:31:02 PST 2008


I run above code in a console using IronPython 2.0 Final Version and here is
the output (on Vista) using Tasklist command. The final result doubles the
in memory size; I stopped the measurement when it hits 12,000

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     33,532 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     39,204 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     43,692 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     42,952 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     45,888 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     45,928 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     45,956 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     44,992 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     49,520 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     50,592 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     50,636 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     52,632 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     52,788 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     52,884 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     53,032 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     62,916 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     62,456 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     67,668 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     65,880 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     72,260 K

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
IronPythonLeaker.exe          5248 Console                    1     73,644 K


On Thu, Dec 25, 2008 at 3:37 PM, Christian Schmidt <
christian2.schmidt at gmx.de> wrote:

> 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
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>



-- 
nomadlife.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20081226/ab3bb844/attachment.htm>


More information about the Users mailing list