[Numpy-discussion] Memory leak in array protocol numarray <--numpy

Todd Miller jmiller at stsci.edu
Sun Aug 13 08:58:52 EDT 2006


Francesc Altet wrote:
> A Dissabte 12 Agost 2006 14:37, Todd Miller va escriure:
>   
>> I agree with all of Travis' comments below and committed the suggested
>> changes to numarray CVS.     I found one other numarray change needed
>> for Francesc's examples to run (apparently) leak-free:
>>
>> Py_INCREF(obj)
>> Py_XDECREF(a->base)
>> a->base = obj
>> Py_DECREF(cobj)
>>
>> Thanks Travis!
>>     
>
> Hey! I checked this morning Travis' patch and seems to work well for me. I'll 
> add yours as well later on and see... BTW, where exactly I've to add the 
> above lines?
>   
The lines above are a modification to Travis' patch,  so basically the 
same place:

*******
        a = NA_FromDimsStridesTypeAndData(arrayif->nd, shape, strides, 
t, arrayif->data);
        if (!a) goto _fail;

!       a->base = cobj;

        return a;

-------
        a = NA_FromDimsStridesTypeAndData(arrayif->nd, shape, strides, 
t, arrayif->data);
        if (!a) goto _fail;

!       Py_INCREF(obj);
!       Py_XDECREF(a->base);
!       a->base = obj;
!       Py_DECREF(cobj);

        return a;

Todd




More information about the NumPy-Discussion mailing list