疑难解答ERROR_NOT_ENOUGH_MEMORY [英] Troubleshooting ERROR_NOT_ENOUGH_MEMORY

查看:843
本文介绍了疑难解答ERROR_NOT_ENOUGH_MEMORY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序在具有 ERROR_NOT_ENOUGH_MEMORY 的一个特定用户的计算机上失败(没有足够的存储可用于处理此命令)。

Our application is failing on one specific user's computer with ERROR_NOT_ENOUGH_MEMORY ("Not enough storage is available to process this command").

该错误显然是在我们使用的Delphi VCL框架内部的某个地方引起的,所以我不知道哪个Windows API函数负责。

The error is apparently being raised somewhere deep within the Delphi VCL framework that we're using, so I'm not sure which Windows API function is responsible.

记忆是否存在问题?致电 GlobalMemoryStatus 提供以下信息:

Is memory a problem? A call to GlobalMemoryStatus gives the following information:


  • dwTotalPhys - 1063150000(〜1 GB)

  • dwAvailPhys - 26735000(〜27 MB)

  • dwAvailPage - 1489000000(〜1.4 GB)

对于我来说,Windows会让可用的物理内存在页面文件中有太多的空间可以让它变得如此之低,但我不会了解Windows的虚拟内存管理,以了解这是否正常o不是。

It seems strange to me that Windows would let the available physical memory get so low when so much space is available in the paging file, but I don't know enough about Windows' virtual memory management to know if this is normal or not. Is it?

如果没有内存,那么哪个资源限制被击中?从我在线阅读, ERROR_NOT_ENOUGH_MEMORY 可能是应用程序遇到任何几个限制(GDI对象,USER对象,句柄等)的结果,而不一定是内存。有没有Windows强制执行什么限制的全面列表?有没有办法找出哪个限制被击中?我试过谷歌,但我找不到任何系统的概述。

If not memory, then which resource limit is being hit? From what I read online, ERROR_NOT_ENOUGH_MEMORY could be the result of the application hitting any of several limits (GDI objects, USER objects, handles, etc.) and not necessarily memory. Is there a comprehensive list of what limits Windows enforces? Is there any way to find out which limit is being hit? I tried Google, but I couldn't find any systematic overview.

推荐答案

这种情况的罪魁祸首是 CreateCompatibleBitmap 。显然,Windows可能会对可用于设备相关位图的内存实施相当严格的系统范围限制(参见,例如,这个邮件列表讨论),即使你的系统有足够的内存和大量的GDI资源。 (这些系统范围的限制显然是因为Windows可能会在视频卡的存储器中分配与设备相关的位图。)

The culprit in this case was CreateCompatibleBitmap. Apparently Windows may enforce fairly strict systemwide limits on the memory available for device-dependent bitmaps (see, e.g, this mailing list discussion), even if your system otherwise has plenty of memory and plenty of GDI resources. (These systemwide limits are apparently because Windows may allocate device-dependent bitmaps in the video card's memory.)

解决方案仅仅是使用与设备无关的位图(DIB) (虽然这些可能不能表现出色)。 此知识库文章介绍如何为设备选择最佳DIB格式。

The solution is simply to use device-independent bitmaps (DIBs) instead (although these may not offer quite as good of a performance). This KB article describes how to pick the optimal DIB format for a device.

资源限制的其他候选人(来自他人的答案和我自己的研究):

Other candidates for resource limits (from others' answers and my own research):


  • GDI资源(从此答案) - 通过 GDIView 轻松检查

  • 虚拟内存碎片(从此答案)

  • 桌面堆 - 请参阅 here 这里

  • GDI resources (from this answer) - easily checked with GDIView
  • Virtual memory fragmentation (from this answer)
  • Desktop heap - see here or here

这篇关于疑难解答ERROR_NOT_ENOUGH_MEMORY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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