Delphi EOutOfResources(GDIError)

时间:2011-05-18 13:59:30

标签: delphi gdi limits eoutofresources

我编写了一个应用程序,其中我发现了EOutofResources错误 将TBitmap32保存到流时,由图形单元的GDIError方法引发。

据我所知,它可能来自gdi限制或堆限制。 我知道,对于该过程,默认限制为10000个句柄。 所以根据任务管理器我的应用报告只有620。

我已经下载并运行了桌面堆信息监控工具,该工具报告了这个:

Desktop Heap Information Monitor Tool (Version 8.1.2925.0)
Copyright (c) Microsoft Corporation.  All rights reserved.
-------------------------------------------------------------
  Session ID:    0 Total Desktop: (  7360 KB -   11 desktops)

  WinStation\Desktop            Heap Size(KB)    Used Rate(%)
-------------------------------------------------------------
  WinSta0\Default                    3072             44.5
  WinSta0\Disconnect                   64              4.5
  WinSta0\Winlogon                    128             10.2
  Service-0x0-3e7$\Default            512             29.1
  Service-0x0-3e4$\Default            512              6.8
  Service-0x0-3e5$\Default            512              6.8
  SAWinSta\SADesktop                  512              0.5
  __X78B95_89_IW\__A8D9S1_42_ID       512              0.5
  Service-0x0-1ae39$\Default          512              2.4
  Service-0x0-12d284a7$\Default       512              2.5
  Service-0x0-1312b6d4$\Default       512             15.0
-------------------------------------------------------------

如上所述,我在winsta0中只使用了44%的桌面堆。

除此之外,还会出现此错误。它从未达到上述限制。 我怎样才能确定问题所在?导致此错误的原因是什么?

由于

2 个答案:

答案 0 :(得分:2)

您可能有资源和/或内存泄漏。

查找内存泄漏
如果您使用FastMM的调试版本,它将在程序关闭时向您显示内存泄漏的报告。

以下文章可以帮助您:
http://wiert.wordpress.com/2009/07/29/delphi-fastmm-using-fastmm4-for-debugging-your-memory-allocations-part-1-introduction/

查找资源泄漏
请注意,FastMM虽然是查找内存泄漏的重要工具,但却找不到资源泄漏 AQTime可以找到这些,它有30天的跟踪期。请查看:
http://smartbear.com/products/development-tools/performance-profiling/

如果您需要开源资源泄漏工具,请尝试:http://www.kbasm.com/denomo.html

好狩猎。

答案 1 :(得分:2)

这可能根本不是资源错误。有时,Delphi会将无法转换为特定错误消息的GDI错误报告为资源不足。请参阅Graphics.pas中的GDIError实现。

如果你可以在IDE中重现这一点,找出它发生在何处/原因的最佳方法可能是在编译器设置中启用Use Debug DCUs选项,并在运行你的app时启用Stop On Delphi Exceptions调试器选项