[Image-SIG] Converting images to palette mode

Evgeny Salmin evg.salmin at gmail.com
Wed Feb 4 11:49:38 CET 2009


Hello.

Seems I found something interesting, please consider att1 code from
libImaging of PIL. I think there is will be a memory leak
if we goto "done" label from while. Heap will not be freed.
I wrote C example which uses ImageNew and ImageQuantize methods. While
debugging it under windows with CRT debug malloc/free it shows that this
code has two leaks. One is 1024 kb and second is 83 byte per image. So I've
just moved ImagingQuantHeapFree(h); call under done label. Since that time
VS does not detects any leaks in my example.

Also I've recompile PIL with my fix and I've checked python script which
gives quantization error. Memory usage is stable now. (I've tested it under
fedora10, not under windows xp yet). My python version is 2.5.2.

I know a bit about PIL internals so maybe I wrong. I'd like to know PIL's
author opinition about this. Thank you.

P.S. median_cut with and without my fix is in attach. I did't make diff,
because as I said I'm may be wrong.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090204/0f6c2e52/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: att1
Type: application/octet-stream
Size: 685 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090204/0f6c2e52/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: att2
Type: application/octet-stream
Size: 685 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090204/0f6c2e52/attachment-0001.obj>


More information about the Image-SIG mailing list