windows 32 位进程在 64 位操作系统上可以访问多少内存?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/639540/
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-09 06:08:40  来源:igfitidea点击:

How much memory can a 32 bit process access on a 64 bit operating system?

windowsmemorywow64

提问by jjxtra

On Windows, under normal circumstances a 32 bit process can only access 2GB of RAM (or 3GB with a special switch in the boot.ini file). When running a 32 bit process on a 64 bit operating system, how much memory is available? Are there any special switches or settings that can change this?

在 Windows 上,在正常情况下,32 位进程只能访问 2GB 的 RAM(或 3GB,在 boot.ini 文件中使用特殊开关)。在 64 位操作系统上运行 32 位进程时,有多少内存可用?是否有任何特殊的开关或设置可以改变这一点?

回答by Michael

2 GB by default. If the application is large address space aware (linked with /LARGEADDRESSAWARE), it gets 4 GB (not 3 GB, see http://msdn.microsoft.com/en-us/library/aa366778.aspx)

默认为 2 GB。如果应用程序知道大地址空间(与 /LARGEADDRESSAWARE 链接),它将获得 4 GB(不是 3 GB,请参阅http://msdn.microsoft.com/en-us/library/aa366778.aspx

They're still limited to 2 GB since many application depends on the top bit of pointers to be zero.

它们仍然限制为 2 GB,因为许多应用程序依赖于指针的最高位为零。

回答by MSN

4 GB minus what is in use by the system if you link with /LARGEADDRESSAWARE.

如果与 /LARGEADDRESSAWARE 链接,则为 4 GB 减去系统正在使用的内容。

Of course, you should be even more careful with pointer arithmetic if you set that flag.

当然,如果你设置了那个标志,你应该更加小心指针运算。

回答by Harm ten Napel

Nobody seems to touch upon the fact that if you have many different 32-bit applications, the wow64 subsystem can map them anywhere in memory above 4G, so on a 64-bit windows with sufficient memory, you can run many more 32-bit applications than on a native 32-bit system.

似乎没有人提到如果你有很多不同的 32 位应用程序,wow64 子系统可以将它们映射到 4G 以上的内存中的任何地方,所以在一个有足够内存的 64 位窗口上,你可以运行更多的 32 位应用程序而不是在本机 32 位系统上。

回答by Ben S

A 32-bit process is still limited to the same constraints in a 64-bit OS. The issue is that memory pointers are only 32-bits wide, so the program can't assign/resolve any memory address larger than 32 bits.

32 位进程仍然受限于 64 位操作系统中的相同约束。问题是内存指针只有 32 位宽,因此程序无法分配/解析任何大于 32 位的内存地址。

回答by Maxim Masiutin

An single 32-bit process under a 64-bit OS is limited to 2Gb. But if it is compiled to an EXE file with IMAGE_FILE_LARGE_ADDRESS_AWAREbit set, it then has a limit of 4 GB, not 2Gb - see https://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx

64 位操作系统下的单个 32 位进程限制为 2Gb。但是,如果将其编译为IMAGE_FILE_LARGE_ADDRESS_AWARE设置了位的 EXE 文件,则它的限制为 4 GB,而不是 2Gb - 请参阅https://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx

The things you hear about special boot flags, 3 GB, /3GBswitches, or /uservaare all about 32-bit operating systems and do not apply on 64-bit Windows.

您听到的有关特殊启动标志、3 GB、/3GB开关或/userva所有关于 32 位操作系统的内容,并不适用于 64 位 Windows。

See https://msdn.microsoft.com/en-us/library/aa366778(v=vs.85).aspxfor more details.

有关更多详细信息,请参阅https://msdn.microsoft.com/en-us/library/aa366778(v=vs.85).aspx

As about the 32-bit operating systems, contrary to the belief, there is no physical limit of 4GB for 32-bit operating systems. For example, 32-bit Server Operating Systems like Microsoft Windows Server 2008 32-bit can access up to 64 GB(Windows Server 2008 Enterprise and Datacenter editions) – by means of Physical Address Extension (PAE), which was first introduced by Intel in the Pentium Pro, and later by AMD in the Athlon processor - it defines a page table hierarchy of three levels, with table entries of 64 bits each instead of 32, allowing these CPUs to directly access a physical address space larger than 4 gigabytes – so theoretically, a 32-bit OS can access 2^64 bytes theoretically, or 17,179,869,184 gigabytes, but the segment is limited by 4GB. However, due to marketing reasons, Microsoft have limited maximum accessible memory on non-server operating systems to just 4GB, or, even, 3GB effectively. Thus, a single process can access more than 4GB on a 32-bit OS - and Microsoft SQL server is an example.

至于 32 位操作系统,与信念相反,32 位操作系统没有 4GB 的物理限制。例如,像 Microsoft Windows Server 2008 32 位这样的 32 位服务器操作系统最多可以访问64 GB(Windows Server 2008 企业版和数据中心版)——通过物理地址扩展 (PAE),它首先由 Intel 在 Pentium Pro 中引入,后来由 AMD 在 Athlon 处理器中引入——它定义了一个三层的页表层次结构,每个表条目为 64 位而不是 32,允许这些 CPU 直接访问大于 4 GB 的物理地址空间——因此理论上,32 位操作系统理论上可以访问 2^64 字节,或 17,179,869,184 GB,但该段是限制为 4GB。但是,由于营销原因,Microsoft 将非服务器操作系统上的最大可访问内存限制为仅 4GB,甚至有效地为 3GB。因此,在 32 位操作系统上,单个进程可以访问超过 4GB 的空间——Microsoft SQL 服务器就是一个例子。

32-bit processes under 64-bit Windows do not have any disadvantage comparing to 64-bit processes in using shared kernel's virtual address space (also called system space). All processes, be it 64-bit or 32-bit, under 64-bit Windows share the same 64-bit system space.

64 位 Windows 下的 32 位进程在使用共享内核的虚拟地址空间(也称为系统空间)方面与 64 位进程相比没有任何劣势。所有进程,无论是 64 位还是 32 位,在 64 位 Windows 下共享相同的 64 位系统空间。

Given the fact that the system space is shared across all processes, on 32-bit Windows, processes that create large amount of handles (like threads, semaphores, files, etc.) consume system space by kernel objectsand can run out of memory even if you have lot of memory available in total. In contrast, on 64-bit Windows, the kernel space is 64-bit and is not limited by 4 GB. All system calls made by 32-bit applications are converted to native 64-bit calls in the user mode.

鉴于系统空间由所有进程共享,在32 位 Windows 上,创建大量句柄(如线程、信号量、文件等)的进程会占用内核对象的系统空间,甚至可能耗尽内存如果您总共有大量可用内存。相比之下,在64 位 Windows 上,内核空间为 64 位,不受 4 GB 的限制。32 位应用程序发出的所有系统调用都转换为用户模式下的本机 64 位调用

回答by Sean

You've got the same basic restriction when running a 32bit process under Win64. Your app runs in a 32 but subsystem which does its best to look like Win32, and this will include the memory restrictions for your process (lower 2GB for you, upper 2GB for the OS)

在 Win64 下运行 32 位进程时,您有相同的基本限制。您的应用程序在 32 但子系统中运行,该子系统尽最大努力看起来像 Win32,这将包括您的进程的内存限制(低 2GB 为您,高 2GB 为操作系统)

回答by BobJ

The limit is not 2g or 3gb its 4gb for 32bit.

32 位的限制不是 2g 或 3gb,而是 4gb。

The reason people think its 3gb is that the OS shows 3gb free when they really have 4gb of system ram.

人们认为它的 3gb 的原因是当他们真的有 4gb 的系统内存时,操作系统显示 3gb 免费。

Its total RAM of 4gb. So if you have a 1 gb video card that counts as part of the total ram viewed by the 32bit OS.

它的总内存为 4GB。因此,如果您有一个 1 GB 的视频卡,它被视为 32 位操作系统查看的总内存的一部分。

4Gig not 3 not 2 got it?

4Gig 不是 3 不是 2 明白了吗?