[IronPython] Embedding IronPython
dinov at microsoft.com
Fri Jan 2 18:59:52 CET 2009
This would appear to be a bad default value for compiling. You can explicitly disable compiling the code as optimized and it will be fully collectible:
var runtime = Python.CreateRuntime();
var engine = runtime.GetEngine("py");
var sum = 0.0;
PythonCompilerOptions pco = (PythonCompilerOptions)engine.GetCompilerOptions();
pco.Module &= ~ModuleOptions.Optimized;
var code = engine.CreateScriptSourceFromString("1.0+2.0").Compile(pco);
sum += code.Execute<double>();
I am inclined to change this, or at least add some other way that makes this more discoverable (e.g. via the Python class). But I think changing the default should probably wait until 2.1 as it could have some small perf surprises for people who are expecting it to be in the more optimal form (globals will be ~10% slower). Longer term we're working w/ the CLR team to get the best of both worlds.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dody Gunawinata
Sent: Wednesday, December 31, 2008 4:35 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Embedding IronPython
Please we need more vote on the memory leak issue because it has huge impact on the usage of Iron Python for the web environment as well.
On Wed, Dec 31, 2008 at 11:50 AM, Christian Schmidt <christian2.schmidt at gmx.de<mailto:christian2.schmidt at gmx.de>> wrote:
CompiledCode cc = src.Compile();
This will leak memory. So you will run out of memory after a while (in our case after 100'000 compiles on x86).
Is this going to work or will I run into threading problems? In other words, is the ScriptEngine thread-safe? Will it serialize all of my cc.Execute() calls? Any other insight into its behavior in this regard would be appreciated.
I think globals and imports will be shared. So modifying them might give unexpected results.
Users mailing list
Users at lists.ironpython.com<mailto:Users at lists.ironpython.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users