在运行 64 位 JVM 的 Windows 10 64 位中用于 Java 进程的最大堆大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43275482/
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
Maximum heap size using for Java process in Windows 10 64 bit running 64 bit JVM
提问by Brother
What is maximum Heap size for Java process running on Windows 10 64 bits, with 64 bits JVM? My machine has 8 GBof RAM. And I am running Java 8. I trying to run BFS on huge graph for experimental purposes. While running BFS I am monitoring Heap size being used in Java Visual VM. According to Visual VM heap utilization is always less than 2000 MB regardless of providing following JVM parameters
在Windows 10 64 位和64 位 JVM上运行的 Java 进程的最大堆大小是多少?我的机器有8 GB的 RAM。我正在运行Java 8。我试图在巨大的图上运行 BFS 以进行实验。在运行 BFS 时,我正在监视Java Visual VM 中使用的堆大小。根据 Visual VM 堆利用率始终小于 2000 MB,无论提供以下 JVM 参数
-Xms2048m
-Xmx3072m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
I did some research over internet but could not find any specific answer related to the system specification I am using. Can a java process use more than 2 GB on Windows 10 64 bit and 64 bit JVM? As Guidelines for Java Heap sizingthe limit for Windows XP/2008/7 is 2 GB.
我在互联网上做了一些研究,但找不到与我正在使用的系统规范相关的任何具体答案。java 进程可以在 Windows 10 64 位和 64 位 JVM 上使用超过 2 GB 的空间吗?作为Java 堆大小调整指南,Windows XP/2008/7 的限制为 2 GB。
回答by Kayaman
On a 64-bit machine, with 64-bit JVM you can work with multi gigabyte heaps (dozens and dozens of GBs). I'm not sure it's limited in any way except by the available memory (and the theoretical address space of a 64-bit pointer).
在 64 位机器上,使用 64 位 JVM,您可以使用多 GB 的堆(几十和几十 GB)。除了可用内存(以及 64 位指针的理论地址空间)之外,我不确定它是否有任何限制。
Of course if you're working with a huge heap, the GC has a lot more work to do and you may find that you need to scale horizontally instead of vertically, to maintain a good performance.
当然,如果你正在处理一个巨大的堆,GC 有更多的工作要做,你可能会发现你需要水平而不是垂直扩展,以保持良好的性能。
If VisualVM isn't showing you using more than 2GB (the initial heap size given with -Xms
), then it probably just doesn't need more than that. You've given the permission to use up to3GB (-Xmx
), but the JVM won't allocate more memory just for the fun of it.
如果 VisualVM 没有显示您使用了超过 2GB(用 给出的初始堆大小-Xms
),那么它可能不需要更多。您已授予最多使用3GB ( -Xmx
)的权限,但 JVM 不会仅仅为了好玩而分配更多内存。
回答by Fairoz
Maximum Heap can be allocated for 32bit JVM is 2^32 = 4G, Again 4gb will be devided into 1+ GB for VM to use for runtime classes. It varies windows it is ~2GB and linux it is ~3GB. As you are using 64bit machine maximum heap available is 2^64 it will be big enough for you to run BFS easily.
可以为 32 位 JVM 分配的最大堆是 2^32 = 4G,同样 4gb 将被分成 1+ GB 供 VM 用于运行时类。它因 Windows 而异,约为 2GB,而 linux 约为 3GB。当您使用 64 位机器时,可用的最大堆是 2^64,它足以让您轻松运行 BFS。
You can monitor the available memory using vm flags "-XX+PrintFlagsFinal | grep -iE HeapSize" will tell you the maximum available heap size that can be used. Configure slightly less than that and start using...
您可以使用 vm 标志监视可用内存,“-XX+PrintFlagsFinal | grep -iE HeapSize”会告诉您可以使用的最大可用堆大小。配置略低于那个并开始使用......
回答by Mohan Raj
There is no definite size you could specify for 64 bit architecture but simple test helps you find what is the maximum contiguous space available or could be allocated for a process. This could be tested as follow by using simple command. Try as below java -Xmx -version If the above command gives result then your system could be allowed to have Xmx to that level, If it fails then you can't specify that value.
您无法为 64 位体系结构指定确定的大小,但简单的测试可帮助您找到可用的最大连续空间或可为进程分配的最大连续空间。这可以使用简单的命令进行如下测试。尝试如下 java -Xmx -version 如果上述命令给出结果,那么您的系统可以允许 Xmx 达到该级别,如果失败,则您无法指定该值。
Few test from system. I tested the value with 20G.40g,100G,160G,300G all these gave java -version output but tried with 1600G that throws the error. Output of the test C:\Users\mpalanis>java -Xmx300G -version
系统测试很少。我用 20G.40g、100G、160G、300G 测试了所有这些都给出了 java -version 输出的值,但尝试使用 1600G 会引发错误。测试的输出 C:\Users\mpalanis>java -Xmx300G -version
java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
java 版本“1.7.0_80”Java(TM) SE 运行时环境(构建 1.7.0_80-b15)Java HotSpot(TM) 64 位服务器 VM(构建 24.80-b11,混合模式)
C:\Users\mpalanis>java -Xmx1600G -version
C:\Users\mpalanis>java -Xmx1600G -version
Error occurred during initialization of VM Unable to allocate 52431424KB bitmaps for parallel garbage collection for the requested 1677805568KB heap.
VM 初始化期间发生错误无法为请求的 1677805568KB 堆分配 52431424KB 位图用于并行垃圾回收。
Error: Could not create the Java Virtual Machine.
错误:无法创建 Java 虚拟机。
Error: A fatal exception has occurred. Program will exit.
错误:发生了致命异常。程序将会退出。
Hope this explanation helps.
希望这个解释有帮助。
回答by ikbel benabdessamad
If you are using IntelliJ Idea as an IDE you can do this directly from it,
如果您使用 IntelliJ Idea 作为 IDE,则可以直接从它执行此操作,
- From the main menu, select Help | Change Memory Settings
- Set the necessary amount of memory that you want to allocate and click Save and Restart.
- 从主菜单中,选择帮助 | 更改内存设置
- 设置您要分配的必要内存量,然后单击保存并重新启动。
This changes the value of the -Xmxoption used by the JVM and restarts IntelliJ IDEA with the new setting.
这会更改JVM 使用的-Xmx选项的值,并使用新设置重新启动 IntelliJ IDEA。