I forgot a disclaimer:

This is all to the best of my knowledge. I'm sure one of the awesome
Cython devs will jump in and correct me ;)



On Sun, Nov 15, 2009 at 3:04 AM, Chris Colbert <[email protected]> wrote:
> AH I see ok. I should have read more carefully (a little late here).
>
> When you commented out the INCREF on the datat, did you also comment
> out PyArray_Set_BASE? If not, that may have been causing the problem.
> If you set the base without INCREF'ing the data, then numpy will
> DECREF that data when python goes to gc the array. Now you've lost a
> reference, and if it went to zero, python then tries to gc an object
> that's still in scope.
>
>
>
> On Sun, Nov 15, 2009 at 2:55 AM, Matthew Brett <[email protected]> 
> wrote:
>> Hi,
>>
>>> But dont forget to set base member pointer
>>> (PyObject *PyArray_BASE(PyObject* arr)) to point to the python data
>>> object, or else you leak a reference, and the memory will never get
>>> freed.
>>
>> Right - for reference that's the
>>
>> PyArray_Set_BASE(narr, data)
>>
>> in the code I posted earlier (brought to you courtesy of Dag Sverre's
>> workaround.h trick).
>>
>> Cheers,
>>
>> Matthew
>> _______________________________________________
>> Cython-dev mailing list
>> [email protected]
>> http://codespeak.net/mailman/listinfo/cython-dev
>>
>
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to