[SciPy-dev] BUG: Memory leak in Numpy

izak marais izakmarais at yahoo.com
Thu Jul 6 08:51:47 CDT 2006


Hi

I'm a new scipy and numpy user, so I don't know if this is the right mailing list to post numpy bugs to or what additional info you'll need, but I have code that leaks memory when accessing a numpy array inside a while loop. 

Here is the script (note that I have spent a great deal of time to isolate the problem to this piece of code, because I worried it might have been my code that's buggy. Therefore the script doesn't actually do anything useful in its isolated state).

def grow_region(image, start):
    import numpy as N     #--------> numpy causes leak
    test_array = N.zeros((316, 316), N.uint8)
    #import Numeric as N2    #--------> Numeric works fine
    #test_array = N2.zeros((316, 316), N2.UInt8)
    print test_array
    remaining_area = 316**2
    print 'Before while loop. press enter to continue'
    raw_input()
    
    while (remaining_area>1):
        remaining_area -=1
        for dr in [-1, 0, 1]:
           for dc in [-1, 0, 1]:
                r = 157 +dr                    
                c =  157 + dc                
        #        test_array[r, c] = 1       #--------> NO leak
                if test_array[r,c] == 0:    #--------> causes leak
                    pass
        #         if test_array[157,157] == 0: #--------> NO leak
        #            pass
        #        test = test_array[r,c]           #--------> causes leak


#test
grow_region(1,1)


I run it on windows XP. The numpy.test(level=1) test executes correctly. I can see it leaks memory by watching the memory usage in the task list. The version/install file of Python  is 'python-2.4.2.msi' and numpy is 'numpy-0.9.8.win32-py2.4.exe'.

Let me know if you need extra info on my setup and how I shoud retrieve it (if it is  non-trivial)

Izak

 		
---------------------------------
Do you Yahoo!?
 Get on board. You're invited to try the new Yahoo! Mail Beta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20060706/f894236a/attachment.html 


More information about the Scipy-dev mailing list