32位系统只能寻址4G空间,64位则是128G

目前(2015年5月),Intel的32位架构下,可使用的地址线是36个,可使用的最大物理地址是2^36B,折合64GB,可用的地址空间是4GB。

以下内容摘自《Intel® 64 and IA-32 Architectures Software Developer's Manual》,3.2节(intel.com/content/dam/w):

Address space — Any task or program running on an IA-32 processor can address a linear address space of up to 4 GBytes (232 bytes) and a physical address space of up to 64 GBytes (236 bytes). See Section 3.3.6, "Extended Physical Addressing in Protected Mode," for more information about addressing an address space greater than 4 GBytes.

64位架构下,地址线是46个,所以最大的物理地址是2^46B,折合64TB,可用地址空间也是这么大(目前为止):

Address space — A task or program running in 64-bit mode on an IA-32 processor can address linear address space of up to 264 bytes (subject to the canonical addressing requirement described in Section 3.3.7.1) and physical address space of up to 246 bytes. Software can query CPUID for the physical address size supported by a processor.

所以内存为什么只有这么大,是Intel手册限制了。

64位环境下,地址空间不是从地址向高地址增长的,而是中间被掏空,两头使用:

<img data-rawheight="205" data-rawwidth="174" src="https://pic3.zhimg.com/50/69dd29146efc89f4f05cd3e8fce11826_hd.jpg" class="content_image" width="174">
再说实际使用中:

虽然32位环境下实际上CPU支持访问大于4G的物理内存,但Windows将此功能屏蔽了,导致了32位Windows实际只能使用4G的物理地址空间,具体原因参见这个回答:为何微软不在新的操作系统中让 32 位支持大于 4GB 的内存? - 北极的回答

然后再说为什么32位Windows中实际可用内存少于4G:

虽然物理地址有4G,但CPU如果要访问你的显卡上的显存,就必须把物理地址空间的一部分用于标识显存,这种技术被称为memory-mapped I/O,这样可以让CPU操作显存像操作内存一样。


在Windows的设备管理器里,查看显卡的属性页里的“资源”,可以看到内存映射的地址范围,实际上不管32位还是64位,都需要占用一部分地址空间,以下是我的电脑的截图:

<img data-rawheight="448" data-rawwidth="404" src="https://pic4.zhimg.com/50/d15b39fa3ff564096dfdc3790e45bcd6_hd.jpg" class="content_image" width="404">
因为32位Windows只有4G的地址空间,可是又被显存占去了一部分,所以可用的地址空间就少于4G了。

实际上不仅仅是显存,你电脑上的PCI控制器,各种网卡、声卡、USB控制器等等都需要占用一定的物理内存,所以最终的后果就是可用的物理地址范围变得特别少,最少可能只有1.99GB,这种限制在32位Windows上是不可改变的。

所以,32位WIN7的可用内存才变得那么少,解决问题的唯一途径是换64位系统,或者Linux。

猜你喜欢

转载自blog.csdn.net/w892824196/article/details/80558114
今日推荐