Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to find out what is leaking GDI Objects

I have an application in Embarcadera RAD Studio 2010 (C++). Is it possible to peek into it to see what would be leaking GDI Objects? A tree structured menu is leaking GDI Objects when text is set to Bold. My guess is that the "original" text is first created and then an instance where it is in bold and the first one is "forgotten about" and leaked.

EDIT: Since no leak is reported usin AQTime, even though is obvoius by looking at Taskmanager, I traced the snippet of code that is creating and not releasing GDI Objects.

...

Msg.WParam=(int)PhysicalListView->Canvas->Handle;
PhysicalListView->Dispatch(&Msg);

... 

PhysicalListView is a pointer to a TListView. As I understand it the classes that start with T is part of the standard Embarcadero classes (correct?).

When I have selected a node in the listview with children that have undecorated text everything works fine. But when one, or more, of the children have bold or underlined text for example the GDI count does not decrease after the Dispatch call.

So my guess is that this is an error in the TListView class. I don't know if this works against WinForms or if it uses it's own solution?

Also, this occurs in Debug mode. I will check if the problem goes away when compiling a release build. If so it indicates a leak in the debug versions of TListView.

EDIT2: I think I have uncovered the problem. The initial message sent included a WM_PAINT and after reading about it this message should not be sent by a client application but is instead used by the system. So I changed this to a WM_PRINT and the leak went away. I don't know why a WM_PAINT was used, prehaps I'm missing some functionality of it... Any ideas why they would have used WM_PAINT?

like image 613
inquam Avatar asked Oct 12 '25 08:10

inquam


1 Answers

Have you tried GdiUsage.exe?

http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=5037&ixReplies=5

like image 165
Peter G. Avatar answered Oct 16 '25 08:10

Peter G.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!