[cairo] Huge leak in Cairo/win32

Owen Taylor otaylor at redhat.com
Thu Feb 24 13:07:21 PST 2005


On Thu, 2005-02-24 at 21:47 +0100, Hans Breuer wrote:

> >>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).

[ Note, academic argument follows, I switched over to the method
  you are suggesting earlier]

Where is your method documented? There is not a single place in
the SDK docs (other than in some of the examples) that I can find
that describes a need to save the initial bitmap and restore it.

It is documented that you can't delete a bitmap selected into a DC,
but once the DC is deleted, the bitmap can't be selected into it,
can it?

> > 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.

That doesn't make sense: with your method the 1x1 bitmap is selected
into the DC when it is destroyed. Windows doesn't delete the
bitmap selected into the DC (or we wouldn't have this leak), so why
is the bitmap deleted in your model?

My assumption is that the 1x1 bitmap is somehow special and magic
and doesn't need to be destroyed. I wouldn't be surprised if it
is a singleton object. Either that or it is automatically tied to the 
DC in some fashion.

Regards,
						Owen





More information about the cairo mailing list