Win32 application windows eventually stop painting on Windows 7

前端 未结 3 683
梦毁少年i
梦毁少年i 2021-01-13 00:31

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

3条回答
  •  轮回少年
    2021-01-13 00:58

    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).

提交回复
热议问题