[cairo] Huge leak in Cairo/win32

Hans Breuer hans at breuer.org
Thu Feb 24 12:47:07 PST 2005


On 24.02.2005 19:08, Owen Taylor wrote:
> On Sun, 2005-02-20 at 21:46 -0500, Owen Taylor wrote:
> 
>>Hans Breuer wrote:
>>
>>>While playing with gtk/win32's Cairo integration I spotted
>>>a huge leak also visible with cairo_snippets_win32. To see
>>>it simply go through the snippets with key 'n' or 'p' and
>>>watch the memory usage with the task manager.
>>>
>>>To plug it apply the attached patch :-)
>>>
>>>The leak was caused by missing 'unselect' of the cairo/win32
>>>internal surface->bitmap. Failing to do so lets the following
>>>DeleteObject(bitmap) call fail as well.
>>>Also in case of a self-created dc that needs to be deleted, too.
>>
>>Stupid question - can't we just delete the DC first rather
>>than after the bitmap? won't that automatically unselect the bitmap
>>and let us delete it afterwards?
> 
For me this sounds like relying on an undocumented side-effect instead
of using the documented way to go. Although it may work on some
platforms it may not on others.
Relying on undocumented behaviour should IMHO be avoided where ever
possible (although I'm a big fan of minimizing code size).

> 
> Tried this and it seemed to work fine, so I committed that change.
> 
Not looking at the code but: isn't this only significantly decreasing
the size of the leak - but still leak? Now the 1x1 pixel sized
bitmap, which initially got selected into the device context.

	Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert



More information about the cairo mailing list