I'm working on some code that computes weighted averages of a series of images. I do this by loading a subset of the large image list (maybe a dozen images at a time), computing their average, and then saving the result image to disk. Once I'm done with that subset, I load a new batch and repeat.
The problem is that over time, I start swapping and eventually get memory-related overflow problems. Here's the output of a typical memory crash: Error in sys.excepthook: Traceback (most recent call last): File "/var/lib/python-support/python2.5/apport_python_hook.py", line 30, in apport_excepthook import apport.report, apport.fileutils File "/var/lib/python-support/python2.5/apport/__init__.py", line 1, in <module> from apport.report import Report File "/var/lib/python-support/python2.5/apport/report.py", line 20, in <module> from problem_report import ProblemReport File "/var/lib/python-support/python2.5/problem_report.py", line 17, in <module> from email.MIMEMultipart import MIMEMultipart File "/usr/lib/python2.5/site-packages/PIL/__init__.py", line 79, in __getattr__ File "email/mime/multipart.py", line 9, in <module> File "email/mime/base.py", line 9, in <module> ValueError: bad marshal data Original exception was: Traceback (most recent call last): File "/home/mark/sandbox/im_retimer/retimer_tester.py", line 24, in <module> imstacklist[i].computeBlendImg() File "/home/mark/sandbox/im_retimer/im_retimer.py", line 80, in computeBlendImg self.tmpImg = Image.blend(self.blackImg, self.imObjStack[i], self.imWeights[i]) File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1944, in blend return im1._new(core.blend(im1.im, im2.im, alpha)) MemoryError The thing is that I have plenty of memory for any given batch. The problem seems to be that PIL or python is not doing a good job of automatically flushing memory of image objects that I don't use anymore. So my question is: is there a way to force the flushing from memory of image objects I no longer need? Any other ideas for managing this kind of overflow? Over time, my program may try to load hundreds of images, but I only need to run computations on a few at a time. thanks mark -- -- Mark Wendell _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig