On Wed, May 7, 2008 at 3:50 PM, Keith Suda-Cederquist <[EMAIL PROTECTED]> wrote: > Hi, > > I'm doing some image processing using PIL and SciPy. Individual images are > 2000x2000 pixels with each pixel being 16 bits, so a single image is around > 7 MB in size. > > I've noticed that while my code is running the amount of memory being used > (as reported by Windows Task Manager) by Python gradually increases. It > continues to increase if I re-run the same code again from within iPython > (everytime I re-run the code the memory used increases by about 300 MB). So > after re-running the code several times (while debugging and/or developing) > I will eventually get a memory exception (<type 'exceptions.MemoryError'>).
7 * 40 is close to 300 so I guess you are somehow not freeing the images. > def function1(filename): > image1=im2array(filename) > #im2array is a function I wrote to open a tiff image as a scipy array > #average the 2000x2000 2d array into a single 2000x1 1d array > # perform some scaling on the 2000x1 1d array > #take the FFT of the 2000x1 1d array > result=[fftpeak, fftmaxamplitude] #output is just two float values > return result > > filenames=['file1.tif','file2.tif',...] #about 40 image filenames in this > list This looks ok, I guess any problem is in im2array. > results=[] > for ind in xrange(0,len(filenames): > results.append(function1(filenames[ind])) This can be written much more simply with a list comprehension: results = [ function1(name) for name in filenames ] Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor