[IronPython] Debugging support PythonEngine

Shri Borde Shri.Borde at microsoft.com
Fri Aug 18 23:05:06 CEST 2006

Setting ClrDebuggingEnabled = true will only leak memory for the code executed using the PythonEngine.ExecuteFile API. Any other evals done by other Python modules that are loaded in the engine (using the import command) and code executed using PythonEngine.Evaluate or PythonEngine.Execute will still DynamicMethods.

However, setting with IronPython.Compiler.Options.GenerateDynamicMethods = false will use AssemblyBuilder for those cases too, and so will leak more memory.

We are working on providing documentation for PythonEngine. For now, the answer is simply that memory used by System.Reflection.Emit.AssemblyBuilder, MethodBuilder, etc. can not be reclaimed whereas memory used by System.Reflection.Emit.DynamicMethod can be reclaimed

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kristof Wagemans
Sent: Thursday, August 17, 2006 11:43 PM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] Debugging support PythonEngine

Leaking memory with IronPython.Compiler.Options.GenerateDynamicMethods = false isn't really a big issue: ClrDebuggingEnabled = true already starts to leak memory (at least that's what the comment says).

Is there any complete documentation about what actions cause memory leaks? By following this mailing list and looking at the source code comments I know of some things, but I'm sure that I don't know all situations. Maybe it would be a good idea to have a setting AllowMemoryLeaks which has a default of false. Whenever you go through a code path that is going to leak memory through code generation you could throw an exception. This way, you know at least that something you're doing is wrong. If you're OK with the memory leak, then you could set AllowMemoryLeaks to true.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Shri Borde
Sent: Thursday 17 August 2006 23:49
To: Discussion of IronPython
Subject: Re: [IronPython] Debugging support PythonEngine

The first issue is probably the same that IL offset 0 does not have any debug information.

Calling the delegate "add" steps into a DynamicMethod which confuses VS. A workaround for now is to add this statement before creating the PythonEngine.
IronPython.Compiler.Options.GenerateDynamicMethods = false;
This disabled the use of DynamicMethods altogether and will instead use AssemblyBuilder. This is not generally recommended or supported since you are going to leak memory since AssemblyBuilder memory cannot be reclaimed. However, VS seems to be better able to deal with AssemblyBuilder during stepping, and it might be good enough for you. This is a case where we will would need to teach the tool (VS) to handle DynamicMethods differently than it currently does.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060818/3c32a313/attachment.html>

More information about the Ironpython-users mailing list