Skip to content

Memory leak in numpy? (Trac #2125) #585

Closed
@numpy-gitbot

Description

@numpy-gitbot

Original ticket http://projects.scipy.org/numpy/ticket/2125 on 2012-05-02 by trac user eschlafly, assigned to unknown.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions