I think I figured out the cause of this.  Some expand methods are
calling expand to do deep=True recursion. For example,
Pow._eval_expand_power_exp().  This results in the hints being called
recursively indefinitely.

I think each hint should only call itself recursively.  I'll try to
make this change and see if it doesn't break anything.

Aaron Meurer

On Mon, Jul 16, 2012 at 7:23 PM, Aaron Meurer <[email protected]> wrote:
> I've been looking into the test_expand() memory leak (e.g., with
> PYTHONHASHSEED=2538990509). Apparently, the problem is not with cse,
> but with expand.  If you put a print statement in expr.py like
>
> diff --git a/sympy/core/expr.py b/sympy/core/expr.py
> index 2a2ae16..38bffcf 100644
> --- a/sympy/core/expr.py
> +++ b/sympy/core/expr.py
> @@ -2645,6 +2645,7 @@ def expand(self, deep=True, modulus=None,
> power_base=True, power_exp=True, \
>              return n.expand(deep=deep, modulus=modulus, **hints)/d
>          for hint, use_hint in hints.iteritems():
>              if use_hint:
> +                print 'expanding %s' % hint
>                  func = getattr(expr, '_eval_expand_'+hint, None)
>                  if func is not None:
>                      expr = func(deep=deep, **hints)
>
> and run the tests with PYTHONHASHSEED=2538990509 (64-bit), you'll get
>
> ...
> expanding mul
> expanding log
> expanding basic
> expanding power_exp
> expanding power_base
> expanding multinomial
> expanding mul
> expanding log
> expanding basic
> expanding power_exp
> expanding power_base
> expanding multinomial
> expanding mul
> expanding log
> expanding basic
> expanding power_exp
> expanding power_base
> expanding multinomial
> expanding mul
> expanding log
> expanding basic
> expanding power_exp
> expanding power_base
> expanding multinomial
> expanding mul
> expanding log
> expanding basic
> expanding power_exp
> expanding power_base
> ...
>
> and so on, infinitely.  Clearly somewhere is not handling the base
> case of recursion correctly, but solving this more generally should
> take care of the problem as well.
>
> Aaron Meurer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to