I've read the max heap size on 32bit Windows is ~1.5GB which is due to the fact that the JVM requires contiguous memory. Can someone explain the concept of "contiguous memory" and why you only have max 1.5GB on Windows?
我已经读过32位Windows上的最大堆大小约为1.5GB,这是因为JVM需要连续的内存。有人可以解释“连续内存”的概念,以及为什么在Windows上只有1.5GB的最大值?
Secondly, what then is the max heap size on 64 bit Windows and why is this different than what's available on 32 bit?
其次,64位Windows上的最大堆大小是什么,为什么这与32位可用的不同?
3 个解决方案
#1
35
The 32-bit/64-bit part is unrelated to Java
32位/ 64位部分与Java无关
It turns out that memory locations in a 32-bit system are referenced by 32-bit unsigned integers. This allows up to 2^32 possible memory locations. Since each location stores 1 byte you get 2^32 bytes or 4 GB if you prefer.
事实证明,32位系统中的内存位置由32位无符号整数引用。这允许最多2 ^ 32个可能的存储位置。由于每个位置存储1个字节,因此您可以获得2 ^ 32个字节或4 GB。
On a 64 bit system there are 2^64 locations, or 16 exabytes.
在64位系统上,有2 ^ 64个位置,或16艾字节。
Now, in Windows, the contiguous part becomes a big issue, but that is just how Windows does things. The idea is that you need to have an entire "uninterrupted" range for your heap. Sadly, Windows allocates some memory somewhere in the middle. This basically leaves you with about half the left side or half the right side, about 1.5-2GB chunks, to allocate your heap.
现在,在Windows中,连续的部分成为一个大问题,但这就是Windows的工作方式。这个想法是你需要为你的堆提供一个完整的“不间断”范围。可悲的是,Windows在中间某处分配了一些内存。这基本上会让你大约一半的左侧或一半的右侧,大约1.5-2GB的块,以分配你的堆。
Check out this question for more details on 32 vs 64 bit.
有关32对64位的更多详细信息,请查看此问题。
Edit: Thanks mrjoltcola for the exa prefix!
编辑:感谢mrjoltcola为exa前缀!
#2
6
Contiguous simply means "without gaps", one long single segment. The amount is limited by how large a segment the OS can map for your process. Whether Java requires a contiguous heap or not is an implementation issue specific to JVM and may not exist for other VMs.
连续只是意味着“没有间隙”,一个长的单一部分。该数量受操作系统可为您的流程映射的段大小的限制。 Java是否需要连续堆是JVM特有的实现问题,而其他VM可能不存在。
#3
4
Contiguous memory is not the problem limiting windows to use only 1.2 GB of heap. Even though min/max heap defined, JVM would occupy max heap from system memory while starting. It will then reference only min heap within the occupied system memory until it had to expand. Contiguous memory of max heap is required to start JVM in most of the implimentation to improve performace.
连续内存不是限制窗口仅使用1.2 GB堆的问题。即使定义了最小/最大堆,JVM也会在启动时占用系统内存的最大堆。然后它将仅引用占用系统内存中的最小堆,直到它必须扩展。在大多数实现中启动JVM需要最大堆的连续内存以提高性能。
As Marcus explained above the limit of 32 bit hardware is 4GB for a single process(thread). Every operating system address this 4GB diffrenetly. 4GB is majorly split as kernel space and user space. In 32 bit windows the max user space is close to 1.5 GB. There is option to boot windows with /3GB switch to have more userspace.
正如Marcus上面解释的那样,对于单个进程(线程),32位硬件的限制为4GB。每个操作系统都能解决这个4GB差异问题。 4GB主要分为内核空间和用户空间。在32位窗口中,最大用户空间接近1.5 GB。可以选择使用/ 3GB开关启动窗口以获得更多用户空间。
#1
35
The 32-bit/64-bit part is unrelated to Java
32位/ 64位部分与Java无关
It turns out that memory locations in a 32-bit system are referenced by 32-bit unsigned integers. This allows up to 2^32 possible memory locations. Since each location stores 1 byte you get 2^32 bytes or 4 GB if you prefer.
事实证明,32位系统中的内存位置由32位无符号整数引用。这允许最多2 ^ 32个可能的存储位置。由于每个位置存储1个字节,因此您可以获得2 ^ 32个字节或4 GB。
On a 64 bit system there are 2^64 locations, or 16 exabytes.
在64位系统上,有2 ^ 64个位置,或16艾字节。
Now, in Windows, the contiguous part becomes a big issue, but that is just how Windows does things. The idea is that you need to have an entire "uninterrupted" range for your heap. Sadly, Windows allocates some memory somewhere in the middle. This basically leaves you with about half the left side or half the right side, about 1.5-2GB chunks, to allocate your heap.
现在,在Windows中,连续的部分成为一个大问题,但这就是Windows的工作方式。这个想法是你需要为你的堆提供一个完整的“不间断”范围。可悲的是,Windows在中间某处分配了一些内存。这基本上会让你大约一半的左侧或一半的右侧,大约1.5-2GB的块,以分配你的堆。
Check out this question for more details on 32 vs 64 bit.
有关32对64位的更多详细信息,请查看此问题。
Edit: Thanks mrjoltcola for the exa prefix!
编辑:感谢mrjoltcola为exa前缀!
#2
6
Contiguous simply means "without gaps", one long single segment. The amount is limited by how large a segment the OS can map for your process. Whether Java requires a contiguous heap or not is an implementation issue specific to JVM and may not exist for other VMs.
连续只是意味着“没有间隙”,一个长的单一部分。该数量受操作系统可为您的流程映射的段大小的限制。 Java是否需要连续堆是JVM特有的实现问题,而其他VM可能不存在。
#3
4
Contiguous memory is not the problem limiting windows to use only 1.2 GB of heap. Even though min/max heap defined, JVM would occupy max heap from system memory while starting. It will then reference only min heap within the occupied system memory until it had to expand. Contiguous memory of max heap is required to start JVM in most of the implimentation to improve performace.
连续内存不是限制窗口仅使用1.2 GB堆的问题。即使定义了最小/最大堆,JVM也会在启动时占用系统内存的最大堆。然后它将仅引用占用系统内存中的最小堆,直到它必须扩展。在大多数实现中启动JVM需要最大堆的连续内存以提高性能。
As Marcus explained above the limit of 32 bit hardware is 4GB for a single process(thread). Every operating system address this 4GB diffrenetly. 4GB is majorly split as kernel space and user space. In 32 bit windows the max user space is close to 1.5 GB. There is option to boot windows with /3GB switch to have more userspace.
正如Marcus上面解释的那样,对于单个进程(线程),32位硬件的限制为4GB。每个操作系统都能解决这个4GB差异问题。 4GB主要分为内核空间和用户空间。在32位窗口中,最大用户空间接近1.5 GB。可以选择使用/ 3GB开关启动窗口以获得更多用户空间。