32 位与 64 位 Windows 版本上的进程大小和行为差异 [英] Process sizes and differences in behaviour on 32bit vs. 64bit Windows versions

查看:31
本文介绍了32 位与 64 位 Windows 版本上的进程大小和行为差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调查我的应用程序的一个奇怪问题,该问题在 2 个版本的 Windows 上的行为不同:

I am investigating a strange problem with my application, where the behaviour is different on 2 versions of Windows:

  • Windows XP(32 位)
  • Windows Server 2008(64 位)

我的发现如下.

在运行我的测试场景时,XML 解析器在解析一个非常大的配置文件期间的某个时间点失败(参见 这个问题 了解更多信息.

When running my test scenario, the XML parser fails at a certain point during the parsing of a very large configuration file (see this question for more information).

发生故障时,进程大小约为 2.3GB.请注意,注册表项已设置为允许进程超过默认的最大进程大小 2GB(在 32 位操作系统上).

At the time of failure, the process size is approximately 2.3GB. Note that a registry key has been set to allow the process to exceed the default maximum process size of 2GB (on 32-bit operating systems).

失败的系统是调用 IXMLDOMDocument::load() 失败,如上面链接的问题所述.

The system of the failure is a call to IXMLDOMDocument::load() failing, as described in the question linked above.

完全在 Windows Server 2008 中运行相同的测试场景——唯一的变量是操作系统.当我在任务管理器下查看我的进程时,它旁边有一个 * 32,我假设这意味着它在 32 位兼容模式下运行.

I run exactly the same test scenario in Windows Server 2008 -- the only variable is the operating system. When I look at my process under Task Manager, it has a * 32 next to it, which I am assuming means it is running in 32-bit compatibility mode.

我注意到,在 Windows XP 上 XML 解析失败时,Windows Server 2008 上的进程大小只有大约 1GB(IOW,大约是 Windows XP 上的进程大小的一半).

What I am noticing is that at the point where the XML parsing fails on Windows XP, the process size on Windows Server 2008 is only about 1GB (IOW, approximately half the process size as on Windows XP).

XML 解析在 Windows Server 2008 上不会失败,一切正常.

The XML parsing does not fail on Windows Server 2008, it all works as it should.

我的问题是:

  1. 为什么 32 位应用程序(以 32 位模式运行)会消耗 64 位操作系统上一半的内存?是真的使用了一半的内存,是普通的虚拟内存不同,还是别的什么?

  1. Why would a 32-bit application (running in 32-bit mode) consume half the amount of memory on a 64-bit operating system? Is it really using half the memory, it is usual virtual memory differently, or is it something else?

承认我的应用程序(似乎)在 Windows Server 2008 上使用了一半的内存,有没有人知道为什么 XML 解析在 Windows XP 上会失败?每次运行测试用例时,都会通过 IXMLDOMParseError 访问错误(请参阅 这个答案) 是不同的.因为这似乎是不确定的,它向我表明我遇到了内存使用问题,而不是处理格式错误的 XML.

Acknowledging that my application (seems) to be using half the amount of memory on Windows Server 2008, does anyone have any ideas as to why the XML parsing would be failing on Windows XP? Every time I run the test case, the error accessed via IXMLDOMParseError (see this answer) is different. Because this appears to be non-deterministic, it suggests to me that I am running into a memory usage problem rather than dealing with malformed XML.

推荐答案

你没有说你是如何观察这个过程的.我假设您使用了 Taskmgr.exe.请注意,它的默认视图在 Memory 列中给出了非常具有误导性的值.它显示工作集大小,即进程正在使用的 RAM 量.这与问题的根源无关,虚拟内存空间不足.没有太多理由假设 Windows 2008 会显示与 XP 相同的值,因为它具有明显不同的内存管理器.

You didn't say how you observed the process. I'll assume you used Taskmgr.exe. Beware that it's default view gives very misleading values in the Memory column. It shows Working set size, the amount of RAM that's being used by the process. That has nothing to do with the source of your problem, running out of virtual memory space. There is not much reason to assume that Windows 2008 would show the same value as XP, it has a significantly different memory manager.

您也可以看到虚拟内存大小,使用视图 + 列.

You can see the virtual memory size as well, use View + Columns.

您的程序不会在 64 位操作系统上爆炸的原因是因为 32 位进程具有接近 4 GB 的可寻址虚拟内存.在 32 位操作系统上,它需要与操作系统共享地址空间,并且只有 2 GB.如果您使用/3GB 启动选项,则更多.

The reason your program doesn't bomb on a 64-bit operating system is because 32-bit processes have close to 4 gigabytes of addressable virtual memory. On a 32-bit operating system, it needs to share the address space with the operating system and gets only 2 gigabytes. More if you use the /3GB boot option.

使用 SAX 解析器避免消耗太多内存.

Use the SAX parser to avoid consuming so much memory.

这篇关于32 位与 64 位 Windows 版本上的进程大小和行为差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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