windows 32 位操作系统上的 JVM 堆大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4080023/
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
JVM Heapsize on 32 bit OS
提问by Aijaaz
I am using 32 bit win.7 and using Eclipse. Also having 4GB RAM.
我正在使用 32 位 win.7 并使用 Eclipse。还有 4GB 内存。
I want to allocate my java application a maximum heapsize of around 3 GB, but I am able to allocate maximum 1.5GB through VM arguments -Xmx1056m
.
我想为我的 java 应用程序分配大约 3 GB 的最大堆大小,但我能够通过 VM arguments 分配最大 1.5GB -Xmx1056m
。
What should I do? If I Install a 64 bit win.7. it would be able then to allocate 3GB heapsize to my app?
我该怎么办?如果我安装 64 位 win.7。那么它可以为我的应用程序分配 3GB 堆大小吗?
回答by jarnbjo
A regular 32-bit Windows process can only address 2GB of memory, even if you have more memory available. You can find the memory limits for different Windows versions here.
常规的 32 位 Windows 进程只能寻址 2GB 的内存,即使您有更多可用内存。您可以在此处找到不同 Windows 版本的内存限制。
Since the VM need memory for more things than just the heap, the max heap size will be slightly less than the maxmimum memory available to the process. Usually, you can tweak the heap up to around 1.6GB for a 32-bit Windows VM.
由于 VM 需要的内存不仅仅是堆,因此最大堆大小将略小于进程可用的最大内存。通常,对于 32 位 Windows VM,您可以将堆调整到大约 1.6GB。
回答by Faisal Feroz
You need a 64bit OS and 64bit VM to allocate this much RAM.
您需要一个 64 位操作系统和 64 位虚拟机来分配这么多 RAM。
回答by Berin Loritsch
I don't have the link right now that describes the JVM memory management process. The limitation you have stumbled upon is a limitation of how Java performs garbage collection. The Java memory heap must be a contigious block. The garbage collection algorithms were optimized for this design limitation so they can perform efficiently. In a 32bit operating system, you are not in control of what memory addresses device drivers are loaded into. On Windows, the OS will only reallocate the device driver base address stored in the DLL if it conflicts with an already loaded code. Other operating systems may reallocate all device drivers on load so they live in a contiguous block near the kernel.
我现在没有描述 JVM 内存管理过程的链接。您偶然发现的限制是 Java 执行垃圾收集方式的限制。Java 内存堆必须是一个连续的块。垃圾收集算法针对此设计限制进行了优化,因此它们可以高效执行。在 32 位操作系统中,您无法控制设备驱动程序加载到的内存地址。在 Windows 上,操作系统只会重新分配存储在 DLL 中的设备驱动程序基地址,如果它与已加载的代码冲突。其他操作系统可能会在加载时重新分配所有设备驱动程序,以便它们位于内核附近的连续块中。
Basically, the limitation is the same for 64bit and 32bit operating systems. It's just on a 64bit OS there are several more address ranges to choose from. Make sure you use a 64bit JVM to match the OS. That's why the 64bit OS is able to find a larger contigious block of memory addresses than the 32bit OS.
基本上,64 位和 32 位操作系统的限制是相同的。它只是在 64 位操作系统上,还有更多地址范围可供选择。确保您使用 64 位 JVM 来匹配操作系统。这就是为什么 64 位操作系统能够找到比 32 位操作系统更大的连续内存块的原因。
EDIT:Additionally the 32bit JVM has a max heap size limit of 2GB.
编辑:此外,32 位 JVM 的最大堆大小限制为 2GB。
REFERENCE:
参考:
Java maximum memory on Windows XP
回答by haylem
What you will need is not only a 64bit OS and a 64bit VM, but also more memory.
您不仅需要 64 位操作系统和 64 位 VM,还需要更多内存。
On a 32bits Windows system the virtual address space is split with 2 GB for kernel operations and 2 GB for user applications. So you're screwed.
在 32 位 Windows 系统上,虚拟地址空间分为 2 GB 用于内核操作和 2 GB 用于用户应用程序。所以你完蛋了。
There's one possible but very unlikely workaround: you can enablethe /3GB switchto raise this limitation and have the system allocate 1GB of virtual address space for for kernel operations and 3GB for user applications (if they are /LARGEADDRESSPACEAWARE).
还有一种可能,但不太可能的解决方法:你可以启用该/ 3GB开关,以提高这一限制,并让系统分配的虚拟地址空间为1GB的内核操作和3GB的用户应用程序(如果他们是/ LARGEADDRESSPACEAWARE)。
Unfortunately, the 32bits Sun/Oracle HotSpot JVM isn't LARGEADDRESSAWARE (that I know of), and other 32bits JVM likely aren't either.
不幸的是,32 位 Sun/Oracle HotSpot JVM 不是 LARGEADDRESSAWARE(据我所知),其他 32 位 JVM 可能也不是。
But think about it: even if you were able to do that, you would use all the memory available for you system. Nothingwould be left for other programs after you've allocated your 3GB of heap for your JVM. Your system would be swapping to disk all the time. It would be unusable.
但是想一想:即使您能够做到这一点,您也会使用系统可用的所有内存。在您为 JVM 分配了 3GB 的堆后,其他程序就不会再剩下任何东西了。您的系统将一直交换到磁盘。它将无法使用。
Just get a 64bis OS with more RAM. That's all there is for you, short of finding ways to have your program use less memory.
只需获得具有更多 RAM 的 64bis 操作系统即可。这就是为您准备的全部内容,还没有找到让您的程序使用更少内存的方法。