[固定]初始堆大小设置为大于最大堆大小的值
In this post, we will how to resolve initial heap size set to a larger value than the maximum heap size
in 爪哇.
问题:初始堆大小设置为大于最大堆大小的值
此错误与 爪哇中的Xmx和Xms参数 这些参数用于提供 虚拟机.
-Xms
:这指定了JVM的初始堆大小
-Xmx
:指定JVM的最大堆内存大小
这只是意味着JVM将以最少Xms的内存数量开始,并且最多可能占用xmx的内存数量。
让’现在重现此错误。
我们将以一个简单的示例说明如何在Java中打印arraylist。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
包 组织.Arpit.爪哇2blog; 进口 爪哇.实用程序.数组列表; 上市 类 PrintArrayListMain { 上市 静态的 虚空 主要(串[] args) { 数组列表<串> countryList=新 数组列表<>(); countryList.加(“印度”); countryList.加(“中国”); countryList.加(“不丹”); 系统.出.打印(countryList); } } |
让’编译并运行代码。
C:\Users\Arpit\Desktop\javaPrograms>爪哇 -Xms1024m -Xmx512m 组织/arpit/java2blog/PrintArrayListMain
VM初始化期间发生错误
初始堆大小设置为大于最大堆大小的值
As you can see, we got the error 初始堆大小设置为大于最大堆大小的值
.
VM初始化期间发生错误
初始堆大小设置为大于最大堆大小的值
解决方案1:初始堆大小设置为大于最大堆大小的值
因为Xms(最小堆大小)大于Xmx(最大堆大小),所以我们收到此错误。
Xms应该总是小于Xmx才能正确运行Java程序。
让’s现在将-Xms更改为512m,将-Xmx更改为1024m。
[印度,中国,不丹]
如您所见,错误现在已解决,我们得到了预期的输出。
那’s all about initial heap size set to a larger value than the maximum heap size
in 爪哇.
解决方案2:为intellij更改vmoptions文件中的Xms值
If you are getting this error in intellij, then you should check Xms value in vmoptions
file.
在Windows上:
您应该能够在Windows上的以下路径中找到文件:
1 2 3 |
C:\程序 档案\JetBrains\IntelliJ 理念 社区 版 2020.2.3\箱子 |
在Mac上:
您应该能够在Mac上的以下路径中找到文件:
1 2 3 |
~/图书馆/偏好/IntelliJIdea2019 .2/idea64.vmoptions |
在Linux上:
您应该能够在以下路径下在Linux上找到该文件:
1 2 3 |
~/.IntelliJIdea2019 .2/配置/idea64.vmoptions |
您应根据上述路径中的intellij版本更改版本。
Check the value of Xms in idea64.vmoptions
file and if it is greater than Xmx or not. If it is greater than Xmx, then we should fix it.
Here is content of idea64.exe.vmoptions
file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
-服务器 -Xms128分钟 -Xmx512m -XX:ReservedCodeCacheSize=240m -XX:+使用ConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50 -ea -XX:CICompilerCount=2 -sun.io.useCanonPrefixCache=假 -杰克.http.认证.挖洞.disableSchemes=” -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -杰克.连接.allowAttachSelf=真正 -Dkotlinx.协程.调试=关 -杰克.模组.非法访问.无声=真正 |
那’s all about how to fix 初始堆大小设置为大于最大堆大小的值
in 爪哇.