26

Leaking GDI objects can be seen from the task manager or from Process Explorer. (Well you don't see the leaks, but you can see if object uasage count continually goes up.)

There are also tools that allow to view GDI objects by type, such as GDIView[a], DeLeaker, DPUS or the GDIDebug (sourecode).

[a] Note that I consider GDIView a great tool to get the job done of identifying and confirming the existance GDI leaks, but it doesn't really help you to find the leaking code in large applications. (I will also note here that the tool works very nicely and seems well behaved, although its homepage is a littlebit weird (-: )

There is also a WinDBG plugin called leaktrap that uses MSs Detours Library.

I also know (and have used) AQTime's Resource Profiler that allows to detect GDI (and other) resource leaks in an application including stack traces for the leaking calls.

Now, my actual question however is: Is it possible to detect leaking GDI objects from within the VC++ debugger? So that one doesn't need a separate tool and GDI leaks can be caught during normal debugging and not have to be checked separately.

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
  • 1
    if I could +2 this question I would. on top of being a good question, you actually provide tons of great info. – tenfour Dec 01 '10 at 10:09

3 Answers3

9

GDI objects do not have to be checked individually (notreally), they can be in charge with Deleaker - and you'll know where the leak. Read the instructions carefully and view a demo video :http://deleaker.com/

John Conde
  • 217,595
  • 99
  • 455
  • 496
MastAvalons
  • 1,150
  • 1
  • 14
  • 23
  • Why would you say that "they don't have to be checked individually"? If an app doesn't properly free GDI Objects, of course I would want to find out which code is leaking ... ?!! – Martin Ba Nov 16 '11 at 07:26
  • 2
    Haven't personally tried this, but I'll mark it as answer anyway. – Martin Ba May 14 '13 at 07:56
  • What a crap! After installing it, the standalone application crashes immediately and the VS plugin shows an empty window! I have the impression that this is a fake. And they want $3999 for a site licence! Ridiculous! Unhandled exception has occurred in your application. Method 'get_CanEnableIme' on type 'DeleakerLibrary.ObjectsControl' from assembly 'DeleakerLibrary, Version=3.0.92.0, Culture=neutral, PublicKeyToken=cd8e4da67e0a5d66' is overriding a method that is not visible from that assembly. – Elmue Feb 09 '16 at 04:28
  • 1
    @Elmue if you googled "Method get_CanEnableIme on" you would see that it's a quite typical issue. To solve it just install SP1 for .Net runtime and it will work. – Artem Razin Jan 12 '17 at 14:37
  • 1
    A software for that expensive price should be able to check the environment that it is running on and give an intelligent error message to the user. A more intelligent software would even detect that problem directly in the installer and tell the user that he has to install SP1. But throwing that exception is really POOR programming. – Elmue Jan 16 '17 at 22:02
3

Intel Parallel Inspector is a memory leak checker that is integrated into Visual Studio and can detect GDI leaks.

ronag
  • 49,529
  • 25
  • 126
  • 221
  • Hmmm ... does this extend the existing visual studio debugger, or is it a separate tool that "just" integrates with Visual Studio? (like AQTime does) – Martin Ba Dec 01 '10 at 10:46
  • 1
    A memory leak checker and a debugger is two different things... and yes it "just" integrates with Visual Studio. – ronag Dec 01 '10 at 11:00
0

Visual Studio doesn't have an inbuilt memory profiler for unmanaged applications.

That is confirmed.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • The question is about GDI resources, not memory. (And VC++ does have built-in tools for tracking memory leaks in _native_ code.) – Adrian McCarthy Nov 15 '11 at 17:42