[NumPy-Tickets] [NumPy] #2125: Memory leak in numpy?

NumPy Trac numpy-tickets@scipy....
Wed May 2 18:43:13 CDT 2012

#2125: Memory leak in numpy?
 Reporter:  eschlafly  |       Owner:  somebody   
     Type:  defect     |      Status:  new        
 Priority:  normal     |   Milestone:  Unscheduled
Component:  Other      |     Version:  1.6.0      
 Keywords:             |  
 Under numpy 1.6.0, the following code leaks about a hundred megs of memory
 for me:

 import numpy
 dtype = [('var1', '100f8')]
 for i in xrange(100000):
     arr = numpy.zeros(1, dtype=[('var1_holder', dtype)])
     arr['var1_holder'] = numpy.zeros(1, dtype=dtype)[0]

 Admittedly, this code should probably trigger some kind of exception
 anyway.  Rewriting the code slightly as below gets rid of the leak:
     arr['var1_holder'][0] = numpy.zeros(1, dtype=dtype)

 Still, I would much rather have had an exception thrown than a silent
 memory leak in otherwise well-behaving code.

Ticket URL: <http://projects.scipy.org/numpy/ticket/2125>
NumPy <http://projects.scipy.org/numpy>
My example project

More information about the NumPy-Tickets mailing list