简体   繁体   English

PAE的.NET OutOfMemory异常

[英].NET OutOfMemory exception with PAE

I have an application running on Windows 2003 x86 with PAE. 我有一个在带有PAE的Windows 2003 x86上运行的应用程序。 OS has 8 GB RAM. 操作系统有8 GB RAM。 During application running some memory is allocated and after the host process grows up to ~1GB and total system memory grows up more than 4GB I got an OOM exception. 在应用程序运行期间,分配了一些内存,在主机进程增长到~1GB并且总系统内存增长超过4GB之后,我得到了一个OOM异常。

At that time there is about 4GB RAM free, about 1GB to 2GB limit for a single process. 当时大约有4GB RAM可用,单个进程大约1GB到2GB。

So the question is: if I have enough free memory, where would be the source of this exception? 所以问题是:如果我有足够的可用内存,那么这个异常的来源是什么?

Remember that answering to the question 'how much memory is my program using?' 请记住回答“我的程序使用了多少内存?”的问题。 is no so simple and answer depends on which counters do you measure. 不是那么简单,答案取决于你测量的是哪些计数器

I would check from start to monitor your application with usage of Process Monitor tool and watch: 我会从开始检查使用Process Monitor工具监视您的应用程序并观察:

  • Private Bytes 私人字节
  • Working Set 工作集
  • Virtual Bytes 虚拟字节

Look also to that question to find more details about different memory usage indicators. 还要查看该问题以查找有关不同内存使用情况指标的更多详细信息。

As I am also a big fan of WinDbg, I would take a full memory dump of the process when OOM exception occurs and analyze it in details. 由于我也是WinDbg的忠实粉丝,我会在发生OOM异常时对进程进行完整的内存转储并详细分析。

What counts is not how much memory the system has available, rather what matters is how much memory your process has available. 重要的不是系统可用的内存量,而是重要的是您的进程可用的内存量。 Since your process is a 32 bit process there is a hard limit of 4GB. 由于您的进程是32位进程,因此硬限制为4GB。

So you don't have 4GB free memory, the system does. 所以你没有4GB可用内存,系统可以。 You have used your allocation of 4GB and you are out of memory. 您已经使用了4GB的分配而内存不足。

The only way forward is to move to a 64 bit process. 前进的唯一方法是转向64位进程。 Clearly that requires a 64 bit system. 显然,这需要64位系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM