Win32应用程序窗口最终停止在Windows 7上绘制 [英] Win32 application windows eventually stop painting on Windows 7

查看:210
本文介绍了Win32应用程序窗口最终停止在Windows 7上绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C ++编写的大型复杂应用程序(没有MFC或.NET)。最积极地使用该软件的客户端将在启动它的一个小时左右内进入所有窗口停止绘画的状态。我们得到报告称应用程序已挂起,因为据他们所知,没有任何事情发生。实际上,应用程序正在运行,只是没有显示任何内容。

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

推荐答案

你可能已经预感到它是什么了 - 你把它放在一边第一句

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


...大型,复杂的应用......

... large, complex application ...

听起来你某处有GDI资源泄漏。要确认这一点,请尝试在GDI对象的任务管理器中查找您的进程。在某些时候,大多数GDI操作都会因您的应用程序而失败。

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.

确保正确释放所有句柄。请注意,不同的GDI对象需要不同的方法来释放对象。例如 GetDC ReleaseDC 释放,但 CreateDC 是由 DeleteDC 释放。

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.

这就是推荐使用RAII智能对象(如智能指针)进行C ++资源管理的原因(由智能对象管理释放,以减少泄漏和错误的可能性。)

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

这篇关于Win32应用程序窗口最终停止在Windows 7上绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆