[Numpy-discussion] Memory leak in array protocol numarray<--numpy

Travis Oliphant oliphant.travis at ieee.org
Fri Aug 11 17:30:51 CDT 2006


Francesc Altet wrote:
> Hi,
>
> I was tracking down a memory leak in PyTables and it boiled down to a problem 
> in the array protocol. The issue is easily exposed by:
>
> for i in range(1000000):
>     numarray.array(numpy.zeros(dtype=numpy.float64, shape=3))
>
>   
More data:

The following code does not leak:

import numpy
import sys

for i in xrange(10000000):
    a = numpy.zeros(dtype=numpy.float64,shape=3)
    b = a.__array_struct__


as verified by watching the memory growth


As far as numpy knows this is all it's supposed to do.   This seems to 
indicate that something is going on inside numarray.array(a)

because once you had that line to the loop, memory consumption shows up.

In fact, you can just add the line

a = _numarray._array_from_array_struct(a)

to see the memory growth problem. 


-Travis




-Travis






More information about the Numpy-discussion mailing list