[SciPy-user] Memory quirk

Anand Patil anand.prabhakar.patil@gmail....
Fri Nov 2 19:03:25 CDT 2007


Hi all,

The following script leaks memory when an array with dtype=object is used
instead of a list. Is this a bug, or a behavior I should be expecting? Any
help is much appreciated.

Thanks,
Anand


from numpy import *
import time
import gc

class MyObject(object):
    def __init__(self):
        self.data = zeros(100000, dtype=float)

        # This leaks memory...
        self.stufflist = array([self], dtype=object)

        # This doesn't
        # self.stufflist = [self]

for i in xrange(10000):
    q=MyObject()
    time.sleep(.01)
    gc.collect()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20071102/cf47a0e8/attachment.html 


More information about the SciPy-user mailing list