On Wednesday 21 January 2009 03:40:00 Sebastian Walter wrote:
> Apparently I have to increase the refcount manually when I return a raw
> PyObject. So I wrote getter functions like that:
>
> PyObject* get_rhs(){
> return incref((PyObject *) _array_my_rhs);
> }
> I'm not sure that this is the way it should be done. But it solved the
> memory corruption problem.
In this case, you are essentially creating a memory leak. The returned array
will never be deleted by python since its reference count will never go to
zero. Please see http://blog.enthought.com/?p=62 for information on fixing
this issue. The code I pointed out earlier encapsulates this using a custom
deleter in C++ which can be used independently of ublas.
Regards,
Ravi
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig