[novak@ucolick.org: Re: integrate.odeint]

I have an extremely unfocused question. I've written a bit of code that uses scipy to compute Lyapunov exponents for a particular dynamical system. The only subtlety (mentioned in a recent e-mail) is that I don't use integrate.odeint() but rather my own home-brew routine that functions like odeint, but instead of taking a python function it takes a string with C code that it compiles (along with an ode integrator from Numerical Recipes) with Weave so that the whole integration happens in C rather than calling back and forth between C/Fortran and Python. Here's the problem: while running last night, this program managed to fill 2 GB of memory and crash. There's no way that 2 GB of memory was required at any given time, so it must be leaking. This is my first real effort in Python, so facing this problem I feel a bit like a babe in the forest. Python has garbage collection and therefore memory leaks must be buried in the "inner workings" of the langauge. Therefore, I'm soliciting advice from the wise men and women of the scipy/python community: what's your strategy for tracking down bugs like this? What sorts of bugs are typical? If I were using the C/Python API directly, I would conclude that I'd messed up reference counts. But the reference counting increment/decrement macros don't appear when you use Weave. So, that's it. Any advice is welcome. Greg

Hi Greg, Are you taking care of freeing memory in the C code? Python knows nothing about the memory being allocated in it, it's garbage collection and would not be applicable here. regards, Ed On Fri, 15 Oct 2004 12:04:05 -0700 Greg Novak <novak@ucolick.org> wrote:
I have an extremely unfocused question.
I've written a bit of code that uses scipy to compute Lyapunov exponents for a particular dynamical system. The only subtlety (mentioned in a recent e-mail) is that I don't use integrate.odeint() but rather my own home-brew routine that functions like odeint, but instead of taking a python function it takes a string with C code that it compiles (along with an ode integrator from Numerical Recipes) with Weave so that the whole integration happens in C rather than calling back and forth between C/Fortran and Python.
Here's the problem: while running last night, this program managed to fill 2 GB of memory and crash. There's no way that 2 GB of memory was required at any given time, so it must be leaking.
This is my first real effort in Python, so facing this problem I feel a bit like a babe in the forest. Python has garbage collection and therefore memory leaks must be buried in the "inner workings" of the langauge.
Therefore, I'm soliciting advice from the wise men and women of the scipy/python community: what's your strategy for tracking down bugs like this? What sorts of bugs are typical? If I were using the C/Python API directly, I would conclude that I'd messed up reference counts. But the reference counting increment/decrement macros don't appear when you use Weave.
So, that's it. Any advice is welcome.
Greg
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.net http://www.scipy.net/mailman/listinfo/scipy-user

Greg Novak wrote:
Therefore, I'm soliciting advice from the wise men and women of the scipy/python community: what's your strategy for tracking down bugs like this? What sorts of bugs are typical? If I were using the C/Python API directly, I would conclude that I'd messed up reference counts. But the reference counting increment/decrement macros don't appear when you use Weave.
If you post some of your code (to a website if it's large), we can provide you more focused advice. -- Robert Kern rkern@ucsd.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
participants (3)
-
Ed Rahn
-
Greg Novak
-
Robert Kern