32 位进程可以在 64 位 Windows 操作系统上访问更多内存吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/570589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 12:01:25  来源:igfitidea点击:

Can a 32bit process access more memory on a 64bit windows OS?

windowsprocessx8664-bit

提问by Ely

From what I understand, a 32bit process can only access 2GB of memory on 32bit windows without the /3GB switch, and that some of that memory is taken up by the OS for its own diabolical reasons. This seems to mesh with my experiences as we have an app that crashes when it reaches around 1.2 - 1.5 GB of RAM with out of memory exceptions, even though there is still plenty of memory available.

据我了解,一个 32 位进程在没有 /3GB 开关的情况下只能访问 32 位窗口上的 2GB 内存,并且由于其自身的恶魔原因,其中一些内存被操作系统占用。这似乎符合我的经验,因为我们有一个应用程序在达到大约 1.2 - 1.5 GB 的 RAM 时会崩溃,并且出现内存不足异常,即使仍有足够的可用内存。

My question is, would moving this 32bit app to 64bit windows allow it access more than the 1.5GB or so memory it can now? Or would the app itself have to be upgraded to 64bit?

我的问题是,将这个 32 位应用程序移动到 64 位窗口是否允许它访问超过 1.5GB 左右的内存?还是应用程序本身必须升级到 64 位?

回答by Evan Teran

Newer versions of Visual Studio have a new flag which make 32-bit apps "big address space aware". Basically what it does is say that if it's loaded on a 64-bit version of windows, then it will get 4GB (the limit of 32-bit pointers). This is certainly better than the 2 or 3 GB you get on 32-bit versions of windows. See http://msdn.microsoft.com/en-us/library/aa366778.aspx:

较新版本的 Visual Studio 有一个新标志,它使 32 位应用程序“识别大地址空间”。基本上它的作用是说,如果它加载到 64 位版本的 Windows 上,那么它将获得 4GB(32 位指针的限制)。这肯定比您在 32 位版本的 Windows 上获得的 2 或 3 GB 更好。请参阅http://msdn.microsoft.com/en-us/library/aa366778.aspx

Most notably it says:

最值得注意的是它说:

Limits on memory and address space vary by platform, operating system, and by whether the IMAGE_FILE_LARGE_ADDRESS_AWARE value of the LOADED_IMAGE structure and 4-gigabyte tuning (4GT) are in use. IMAGE_FILE_LARGE_ADDRESS_AWARE is set or cleared by using the /LARGEADDRESSAWARE linker option.

内存和地址空间的限制因平台、操作系统以及是否使用 LOADED_IMAGE 结构的 IMAGE_FILE_LARGE_ADDRESS_AWARE 值和 4 GB 调整 (4GT) 而异。IMAGE_FILE_LARGE_ADDRESS_AWARE 使用 /LARGEADDRESSAWARE 链接器选项设置或清除。

Also see: http://msdn.microsoft.com/en-us/library/wz223b1z.aspx

另请参阅:http: //msdn.microsoft.com/en-us/library/wz223b1z.aspx

回答by jalf

Yes, under the right circumstances, a 32-bit process on Windows can access a full 4GB of memory, rather than the 2Gb it's normally limited to.

是的,在适当的情况下,Windows 上的 32 位进程可以访问完整的 4GB 内存,而不是通常限制为 2Gb。

For this to work, you need the following:

为此,您需要以下内容:

  • The app must be running on a 64-bit OS
  • The app must be compiled with the /LARGEADDRESSAWARE flag.
  • The app should be tested to make sure it actually works properly in this case. ;) (specifically, code that relies on all pointers pointing to addresses below the 2GB boundary will obviously not work here)
  • 该应用程序必须在 64 位操作系统上运行
  • 必须使用 /LARGEADDRESSAWARE 标志编译应用程序。
  • 应测试该应用程序以确保它在这种情况下确实可以正常工作。;)(具体来说,依赖所有指向 2GB 边界以下地址的指针的代码在这里显然不起作用)

回答by chollida

Your app will be limited by the pointer size, in your example 32 bits.

您的应用程序将受到指针大小的限制,在您的示例中为 32 位。

If your app was to access more memory then you would need some sort of segmented memory architecture like we had in the 16 bit days where apps used 16bit pointers and offsets to access the full 32bit memory space.

如果您的应用程序要访问更多内存,那么您将需要某种分段内存架构,就像我们在 16 位时代那样,应用程序使用 16 位指针和偏移量来访问完整的 32 位内存空间。

回答by vartec

WOW64 allows using 32-bit Windows application on 64-bit Windows, translating 32-bit pointers to real 64-bit pointers. And actually 32-bit addressing should allow accessing 4GB of memory.

WOW64 允许在 64 位 Windows 上使用 32 位 Windows 应用程序,将 32 位指针转换为真正的 64 位指针。实际上 32 位寻址应该允许访问 4GB 的内存。