views:

362

answers:

1

It seems that DrawFrameControl() creates Font and Brush objects, select them into dc, and doesn't delete them. (according to BoundsChecker messages). Does anyone faced such thing?

+2  A: 

I have experienced the same in various OS/CRT Dlls. One of the patterns is where

  • I get the DC of a window (GetDC or GetWindowDC) in order to perform whatever operation I like (i.e. creating a compatible memory DC).
  • I release the DC after I am done with it, and even if I do not select any GDI objects in it I sometimes get a Boundschecher warning stating that there are still selected objects in the device context.

Since these warnings are definitely not in my code, I would advise on taking them with a grain of salt. Generally what I do is I cleanup any BC warnings that have a reference to my code.

Off topic: BC throws a lot of warnings that a developer can not fix in his code. In stl you will have a myriad of warnings, but most of them are "comparing unrelated pointer". This does not mean that BC is mistakenly throwing them. "Comparing unrelated pointer" in a regular app can be a disaster, but I think the guys that wrote the stl implementation know what they are doing and probably have examined those cases anyway.

Dan Cristoloveanu
Unfortunatelly in my case there is definitely a leak, beacause the quantity on GDI objects raises to several thousands during several seconds, and then GDI crashes.
cos