If explicit "del" appears to address a leak that Python's builtin refcounter doesn't handle, that's more of a bug in Python than in PIL ;-)
I'm not 100% sure, but I think the rationale for including the explicit "del" in that example is that the draw object holds a reference to the image you're drawing in; by doing an explicit del, you minimize the risk that the program hangs on to potentially large image objects without you noticing. (I wouldn't rule out a memory leak either, of course; if you can find a small example that leaks when executed in a loop, let me know). </F> On Mon, Nov 3, 2008 at 11:24 PM, Ned Batchelder <[EMAIL PROTECTED]> wrote: > In the docs for ImageDraw > (http://www.pythonware.com/library/pil/handbook/imagedraw.htm), the example > includes "del draw". I don't understand why that line is necessary, since > when the variable goes out of scope, the object will be deleted. > But in our unit tests, we had a problem with memory use growing too large to > complete the tests. By adding some "del draw" lines into our code, we > halved the memory requirement. In all cases, these dels were in places > where the variable would go out of scope or be overwritten shortly anyway. > Why are the dels necessary? Is this a subtle memory management bug in > ImageDraw? > > --Ned. > http://nedbatchelder.com > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig