[NumPy-Tickets] [NumPy] #1548: matrix unbounded memory leak using +=
NumPy Trac
numpy-tickets@scipy....
Wed Jul 28 18:36:21 CDT 2010
#1548: matrix unbounded memory leak using +=
--------------------------------+-------------------------------------------
Reporter: cardinal | Owner: somebody
Type: defect | Status: needs_review
Priority: high | Milestone: 1.5.0
Component: numpy.core | Version: devel
Keywords: matrix memory leak |
--------------------------------+-------------------------------------------
Changes (by pv):
* status: new => needs_review
Comment:
I take that back, that's probably not the correct fix since our docs say
things go otherwise.
This might be a correct fix:
{{{
diff --git a/numpy/core/src/multiarray/methods.c
b/numpy/core/src/multiarray/met
index 0d7180a..7835549 100644
--- a/numpy/core/src/multiarray/methods.c
+++ b/numpy/core/src/multiarray/methods.c
@@ -843,6 +843,12 @@ array_preparearray(PyArrayObject *self, PyObject
*args)
return NULL;
}
+ if (Py_TYPE(self) == Py_TYPE(arr)) {
+ /* No need to create a new view */
+ Py_INCREF(arr);
+ return arr;
+ }
+
Py_INCREF(PyArray_DESCR(arr));
ret = PyArray_NewFromDescr(Py_TYPE(self),
PyArray_DESCR(arr),
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1548#comment:5>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list