为什么我的 Windows 程序会死掉并显示冻结(蓝灰色)的窗体或窗口?

发布于 2024-12-11 19:31:54 字数 189 浏览 0 评论 0原文

我在 Windows 7 上的 delphi 程序(不适用于 .NET)似乎连续运行了几天,然后该程序有点冻结,其所有窗口都涂上了蓝灰色,就好像其窗口被禁用一样。您根本无法再控制该程序,而必须终止其进程并重新启动它。您不需要重新启动系统本身。

有没有人经历过这个或类似的事情?如果是这样,您采取了什么措施来解决或尝试解决它?

谢谢,

My delphi program (NOT for .NET) on windows 7 seems to be running for couple of days straight and then the program sort of freezes with all of its windows painted with blueish grey color as if its windows are disabled. You simply don't have control over the program anymore but has to kill its process and start it up again. You don't need to reboot the system itself.

Has anyone experience this or anything similar? If so, what did you do to resolve or try to resolve it?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

人间☆小暴躁 2024-12-18 19:31:54

你的问题上下文非常模糊。我们没有关于您的应用程序的任何信息,甚至其设计和架构。

尽管如此,我的(通用)建议如下:

  • 如果您的应用程序不是多线程的,请在后台线程中进行处理,然后让主线程准备好处理 GDI 消息;
  • 如果您的应用程序是多线程的,请注意来自后台线程的所有 VCL 访问都是通过 Synchronize 调用进行的;
  • 如果您的应用程序是多线程或使用计时器,请注意没有方法是可重入的(在某些情况下,您可能会遇到 竞争条件);
  • 寻找任何内存泄漏;
  • 使用程序执行的详细日志记录,记录所有异常< /a> 上升,猜测程序挂起的上下文(也可以在客户端使用它来寻找竞争条件);
  • 下载名为 ProcessExplorer 的强大免费工具(现已由 Microsoft 托管),然后查看冻结程序的状态:您将看到有关线程、CPU 使用、内存、网络、库、句柄的详细信息 - 这是任何认真调试的必备条件 - 特别跟踪 GDI 句柄 泄漏(其中的数量应保持稳定);
  • 如果你还没有检查过,请查看全局 Windows 系统事件日志:这里可能有一些信息;
  • 也许第三方组件或库是导致进程挂起的原因:尝试隔离可能导致此挂起的代码部分。

我的 Delphi 应用程序运行了几个月没有任何问题。问题肯定是在应用程序代码中,而不是在 Delphi 架构中(它的 RTL 和 VCL 非常稳定)。

Your question context is very vague. We do not have any information about your application, even its design and architecture.

Nethertheless, my (general-purpose) suggestions are the following:

  • If your application is not multi-threaded, do the process in background threads, then leave the main thread ready to process GDI messages;
  • If your application is multi-threaded, take care that all VCL access from background threads are made via a Synchronize call;
  • If your application is multi-threaded or use timers, take care that no method is re-entrant (in some circonstances, you may come into a race condition);
  • Hunt any memory leak;
  • Use a detailed logging of the program execution, logging all exceptions risen, to guess the context of the program hang (it may be used on the customer side also to hunt race conditions);
  • Download the great free tool named ProcessExplorer (now hosted by Microsoft), and check out the state of your frozen program: you will see detailed information about threads, CPU use, memory, network, libraries, handles - this is a must have for any serious debugging - track especially the GDI handles leaks (number of those should remain stable);
  • If you did not check it already, take a look at the global Windows system event log: there may be some information here;
  • Perhaps a third party component or library is responsible of the process hang: try to isolate the part of your code which may be responsible of this hang.

I've Delphi application running for months without any problem. Issue is definitively in application code, not in the Delphi architecture (its RTL and VCL are very stable).

风尘浪孓 2024-12-18 19:31:54

蓝灰色可能是默认的窗口颜色,这意味着窗口不再自行绘制。这与程序不再响应任何输入的另一个症状一致。这意味着它不处理任何窗口消息。

最简单的调试方法是在调试器中运行程序,当程序挂起时,将其停止并查看它在哪里。

如果发生内存泄漏,您最终可能会耗尽进程空间中的内存,并且程序可能无法正确响应该情况。检查任务管理器以查看其使用的内存量。

The bluish grey color is probably the default window color, meaning the window is no longer painting itself. This is consistent with the other symptom that the program no longer responds to any input. This means it isn't processing any window messages.

The easiest way to debug is to run the program in a debugger, and when it's hung just stop it and see where it's at.

If you have a memory leak you may eventually run out of memory in your process space, and it's possible that the program doesn't properly respond to that condition. Check Task Manager to see the amount of memory it's using.

装迷糊 2024-12-18 19:31:54

是的,我在过去几年修复了一些挂起和其他问题。

我之前使用过ProcessExplorer(查看堆栈),但它需要Microsoft调试符号。使用 Delphi,您只能创建 .map 文件。使用map2dbg,我可以将.map转换为.dbg,但这并不总是有效(注意:.dbg已被弃用,较新版本的Microsoft调试工具不再使用它们)。

所以我制作了自己的工具:-)
它是“AsmProfiler Sampling”工具的一部分:
http://code.google.com/p /asmprofiler/downloads/detailname=AsmProfiler_Sampling%20v1.0.7.13.zip
点击第一个屏幕中的“进程堆栈视图”按钮。
然后从列表中选择您的进程并双击它:
http://code.google.com/p/asmprofiler/wiki/ProcessStackViewer

现在您可以查看每个线程的堆栈跟踪。如果 GUI 没有响应,则主线程挂起,因此请检查第一个线程。 (注意:有时您会看到一个“空”堆栈,因为函数未对齐堆栈进行计算等,请使用原始轨迹跟踪算法再次获取更多完整堆栈(有很多误报,因为堆栈上的每个指针都是可能会显示一个函数!))。
如果您无法解决,请将堆栈贴在这里,以便我们查看。

注意:它使用 JEDI 库的 jclDebug.pas 单元,因此它可以读取 .map 和 .jdbg 文件(也可以读取 Windows dll 的 .dbg 和 .pdb 调试文件)以及内部 JCLDEBUG 部分(在一个 . EXE文件)。因此,您至少必须构建一个包含详细(!)映射文件的 .exe,请参阅项目选项 ->编译器->链接。

Yes I fixed several hangs and other problems in the past years.

I used ProcessExplorer before (to view the stack), but it needs Microsoft debug symbols. And with Delphi you can only create a .map file. With map2dbg I could convert the .map to a .dbg, but this does not always work (note: .dbg is deprecated, newer versions of Microsoft debugging tools do not use them anymore).

So I made my own tool :-)
It is part of "AsmProfiler Sampling" tool:
http://code.google.com/p/asmprofiler/downloads/detailname=AsmProfiler_Sampling%20v1.0.7.13.zip
Click on the "Stack view of Process" button in the first screen.
Then select your process from the list and double click on it:
http://code.google.com/p/asmprofiler/wiki/ProcessStackViewer

Now you can view the stack trace of each thread. If the GUI does not respond, the main thread hangs, so check the first thread. (note: sometimes you see an "emtpy" stack because a function misaligned the stack for calculation etc, use the raw strack tracing algoritm to get more the full stack again (with a lot of false positives, because every pointer on the stack which is possible a function is shown!)).
Please post the stack here if you can't solve it, so we can take a look at it.

Note: it uses the jclDebug.pas unit of the JEDI library, so it can read .map and .jdbg files (also .dbg and .pdb debug files of Windows dlls) and also internal JCLDEBUG sections (embedded .jdbg file in one .exe). So you must at least build an .exe with detailed (!) map file, see Project Options -> Compiler -> Linking.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文