[IronPython] Memory leak in PythonEngine.Evaluate ?
martmaly at exchange.microsoft.com
Sat Sep 3 02:46:38 CEST 2005
I believe I haven't yet responded to your questions. Sorry for the
> First I iterated the Embed1 sample 10 000 times. Unfortunately this
> in big increase in memory allocation (from 10K to >100K confirmed both
> Manager and with perfmon). I started looking at PythonEngine
> and it looks that although I can create its instance all calls are
> to a static global object. This doesn't "smells" nice.
This does not necessarily have to be a bad sign. The Evaluate method
parsing the expression, generating code and then executing it. There is
smart caching in place that would detect repetitive expressions and
the code. Either way, the memory is garbage collected (including the
code) so when the time comes (it depends on many variables garbage
monitors when that time comes) memory will get collected.
Pre-compiling the expression certainly helps as you have observed and I
that adding Compile method (equivalent to built-in compile function) on
PythonEngine is a good idea.
> So I wonder what happens in the PythonEngine that makes this huge
> Another question is, why Expr.Evaluate() is marked as "experimental"
and if it
> is safe to use it?
Good question. As part of the performance boosts, it may make sense to
expression rather than parse/generage code/execute for certain kinds of
This code is not currently used (Options.FastEval is set to false) so
perspective there may be some bugs in the fast eval code path that we
I hope this helps
More information about the Ironpython-users