[Image-SIG] ImageDraw leaks unless deleted?

Ned Batchelder ned at nedbatchelder.com
Mon Nov 3 23:24:05 CET 2008


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



More information about the Image-SIG mailing list