[Numpy-discussion] Solving a memory leak in a numpy extension; PyArray_ContiguousFromObject

Dan S dan.s.towell+numpy@gmail....
Mon Apr 20 08:08:57 CDT 2009

2009/4/20 "V. Armando Solé" <sole@esrf.fr>:
> Dan S wrote:
>> But as you can see, my C code doesn't perform any malloc() or
>> suchlike, so I'm stumped.
>> I'd be grateful for any further thoughts
> Could it be your memory leak is in:
> return PyFloat_FromDouble(3.1415927); // temporary
> You are creating a "python float object" from something. What if you
> return Py_None instead of your float?:
> Py_INCREF(Py_None);
> return PyNone;
> I do not know if it will help you but I guess it falls in the "any
> further thought" category  :-)

Thanks :) but that doesn't alter things. In fact:

I found the real source of the problem. Namely: I was doing

  #include "Numeric/arrayobject.h"

when I should have been doing

  #include "numpy/arrayobject.h"

Therefore I was compiling against the old deprecated version of the
lib, which presumably had a memory leak inside itself which got fixed
in the intervening years. Using the up-to-date lib, no leak.

Thanks all, anyway!


More information about the Numpy-discussion mailing list