Jon Vance
Jon Vance

Reputation: 504

Win32 application windows eventually stop painting on Windows 7

I have a large, complex application written in C++ (no MFC or .NET). The client that uses the software most aggressively will, within an hour or so of starting it, get to a state where all the windows stop painting. We get reports that the application has "hung" because as far as they can tell nothing is happening. In reality, the application is functioning, just not displaying anything.

I've tried a lot of different things to no avail. I'm out of ideas...

Upvotes: 6

Views: 701

Answers (3)

rodrigo
rodrigo

Reputation: 98368

I'd bet that the application is leaking GDI objects, and when the GDI dedicated space for this process is exhausted, it can no longer paint itself.

You can check if this is the case by adding to the Windows Task Manager (or any other process manager such as Process Monitor) the column GDI Objects and see if this number grows unbounded with time.

Upvotes: 5

Neil
Neil

Reputation: 55392

Your application may actually be suffering from an exception that is getting ignored. See Microsoft KB article 976038.

Upvotes: 0

tenfour
tenfour

Reputation: 36896

You probably already have a hunch of what it is - you give it away in the first sentence

... large, complex application ...

It sounds like you have a GDI resource leak somewhere. To confirm this try looking in task manager at GDI objects for your process. At some point most GDI operations will fail for your application.

Make sure you are freeing all handles correctly. Note that different GDI objects require different methods of freeing the object. For example GetDC is freed by ReleaseDC, but CreateDC is freed by DeleteDC.

This is why RAII smart objects (like smart pointers) are recommended for resource management in C++ (where freeing is managed by the smart object to reduce the likelihood of leaks and errors).

Upvotes: 11

Related Questions