08.03.2012 17:37, Christoph Gohle kirjoitti:
> thanks for testing. I have now tried on different platforms. I get
> all kinds of crashes on os x (now with numpy 1.6.1) and windows
> with numpy 1.6.0. On Ubuntu with numpy 1.3.0 I get a hughe memory
> leak...
> 
> Any hints would be welcome.

The type object inherits `tp_alloc` from Numpy. This routine always
allocates memory of size NPY_SIZEOF_PYARRAYOBJECT for the
PyArrayObject. Therefore, the write to new->unit in your
__array_finalize__ goes to unallocated memory.

This is probably a bug in Numpy --- arrayobject.c:array_alloc should
respect the size specified by the subtype.

A workaround is probably to specify a suitable tp_alloc routine yourself:

   PyType_GenericAlloc,        /* tp_alloc */
    unitArray_new,              /* tp_new */
    _PyObject_Del               /* tp_free */

-- 
Pauli Virtanen

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to