开发者

Is it possible to find out what is leaking GDI Objects

开发者 https://www.devze.com 2023-03-09 17:53 出处:网络
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 B

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开发者_StackOverflow 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?


Have you tried GdiUsage.exe?

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


Memory Validator is a tool we use at work, which handles all types of memory leaks, including gdi objects.


AQTime is my tool of choice. It's a profiler and brings many more features than just GDI leak detection. RAD Studio XE comes with the Standard version of AQTime. For the Pro version you need to pay more.

0

精彩评论

暂无评论...
验证码 换一张
取 消