[Numpy-discussion] Memory leak in ndarray, more info
Sun Oct 28 19:28:53 CDT 2007
On Friday 26 October 2007 05:39, Robert Crida wrote:
> I recently posted about a memory leak in numpy and failed to mention the
> version. The leak manifests itself in numpy-220.127.116.11 but is not present in
> The following code reproduces the bug:
> import numpy as np
> a = np.array([1.0, 2.0, 3.0])
> while True:
> b = str(a)
> What happens above is that is repeatedly converted to a string. The process
> size grow quite rapidly.
> Has anyone else come across this? Where do I look to try to correct it?
Debugging exposes numpy.core.umath.seterrobj as the source, so you can get
even faster memory growth with this (around 30MB/s on my machine):
pyvals = numpy.core.umath.geterrobj()
That is actually ufunc_seterr in trunk/numpy/core/src/ufuncobject.c... which
calls ufunc_update_use_defaults as of r3040. A call to Py_DECREF(errobj) is
missing there after calling PyUFunc_GetPyValues.
So using the following patch on the current svn revision of ufuncobject.c
should fix this leak:
written by Karol Langner
Sun Oct 28 20:00:47 EDT 2007
More information about the Numpy-discussion