简体   繁体   English

了解最大JVM堆大小 - 32位与64位

[英]Understanding max JVM heap size - 32bit vs 64bit

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. 我已经读过 32位Windows上的最大堆大小约为1.5GB,这是因为JVM需要连续的内存。 Can someone explain the concept of "contiguous memory" and why you only have max 1.5GB on Windows? 有人可以解释“连续内存”的概念,以及为什么在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位可用的不同?

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. 事实证明,32位系统中的内存位置由32位无符号整数引用。 This allows up to 2^32 possible memory locations. 这允许最多2 ^ 32个可能的存储位置。 Since each location stores 1 byte you get 2^32 bytes or 4 GB if you prefer. 由于每个位置存储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. 现在,在Windows中,连续部分成为一个大问题,但这就是Windows的工作方式。 The idea is that you need to have an entire "uninterrupted" range for your heap. 这个想法是你需要为你的堆拥有一个完整的“不间断”范围。 Sadly, Windows allocates some memory somewhere in the middle. 可悲的是,Windows在中间某处分配了一些内存。 This basically leaves you with about half the left side or half the right side, about 1.5-2GB chunks, to allocate your heap. 这基本上会让你大约一半的左侧或一半的右侧,大约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前缀!

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可能不存在。

Contiguous memory is not the problem limiting windows to use only 1.2 GB of heap. 连续内存不是限制窗口仅使用1.2 GB堆的问题。 Even though min/max heap defined, JVM would occupy max heap from system memory while starting. 即使定义了最小/最大堆,JVM也会在启动时占用系统内存的最大堆。 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. 在大多数实现中启动JVM需要最大堆的连续内存以提高性能。

As Marcus explained above the limit of 32 bit hardware is 4GB for a single process(thread). 正如Marcus上面解释的那样,对于单个进程(线程),32位硬件的限制为4GB。 Every operating system address this 4GB diffrenetly. 每个操作系统都能解决这个4GB差异问题。 4GB is majorly split as kernel space and user space. 4GB主要分为内核空间和用户空间。 In 32 bit windows the max user space is close to 1.5 GB. 在32位窗口中,最大用户空间接近1.5 GB。 There is option to boot windows with /3GB switch to have more userspace. 可以选择使用/ 3GB开关启动窗口以获得更多用户空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM