java Intellij 堆大小,初始堆大小设置为大于最大堆大小的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47066443/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 09:29:34  来源:igfitidea点击:

Intellij heap size, Initial heap size set to a larger value than the maximum heap size

javamemoryintellij-ideaheap-memory

提问by ???

I'm a beginner in Java, and I just started using Intellij as my IDE.

我是 Java 初学者,刚开始使用 Intellij 作为我的 IDE。

When I use it, sometimes it's delayed.

当我使用它时,有时会延迟。

I changed my xms and xmx for larger heap size (xms = 1024, xmx = 2048), but it throws an error.

我更改了我的 xms 和 xmx 以获得更大的堆大小(xms = 1024,xmx = 2048),但它引发了错误。

So, I rolled it back.

所以,我把它回滚了。

The error message was something like this: "Initial heap size set to a larger value than the maximum heap size".

错误消息是这样的:“初始堆大小设置为比最大堆大小更大的值”。

What is the problem?

问题是什么?

If possible, how do I increase maximum heap size?

如果可能,如何增加最大堆大小?

I'm using a laptop and it has 8GB memory. x64 Intellij.exe used.

我正在使用笔记本电脑,它有 8GB 内存。使用 x64 Intellij.exe。

回答by BrianC

If you are seeing this error in InteliJ after the 2019.2 update it is because the update changed the JVM XMX value to 2048m without checking the related values which can allow XMS to become larger than the max XMX value which is not valid and creates that error.

如果您在 2019.2 更新后在 InteliJ 中看到此错误,那是因为更新将 JVM XMX 值更改为 2048m,而没有检查相关值,这可能会使 XMS 变得大于无效的最大 XMX 值并产生该错误。

i.e. The values for me had been XMX=6000m and XMS=4096m but after the 2019.2 update they were XMX=2048m and XMS=4096m

即我的值是 XMX=6000m 和 XMS=4096m 但在 2019.2 更新之后它们是 XMX=2048m 和 XMS=4096m

You will have to manually change the values so XMS is equal to or less than XMX. On Macs the VM options file is ~/Library/Preferences/IntelliJIdea2019.2/idea.vmoptions

您必须手动更改这些值,以使 XMS 等于或小于 XMX。在 Mac 上,VM 选项文件是 ~/Library/Preferences/IntelliJIdea2019.2/idea.vmoptions

NOTE: That path assumes you are on InteliJ version 2019.2. You will need to change that value in the path to the version you are on if

注意:该路径假设您使用的是 InteliJ 版本 2019.2。如果出现以下情况,您将需要在您所在版本的路径中更改该值

回答by Mijo

I had the same issue on Linux. The configuration file is found in ~/.IntelliJIdea2018.2/config/idea64.vmoptionsThe directory will look like ~/.IntelliJIdeayyyy.n/config where yyyy is the year, and n is the release number in that year. Make sure that the -Xmsvalue is higher than the -XmxHere is my working config for ubuntu 18.04 with 8GB RAM

我在 Linux 上遇到了同样的问题。配置文件位于 ~/.IntelliJIdea2018.2/config/idea64.vmoptions目录将类似于 ~/.IntelliJIdeayyyy.n/config 其中 yyyy 是年份,n 是该年份的版本号。确保该 -Xms值高于-Xmx这里是我的 8GB RAM 的 ubuntu 18.04 的工作配置

# custom IntelliJ IDEA VM options

-server
-Xms4096m
-Xmx4096m
-XX:NewSize=1024m
-XX:MaxNewSize=1512m
-XX:NewRatio=1
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
-XX:SurvivorRatio=8
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:+CMSParallelRemarkEnabled
-XX:CMSInitiatingOccupancyFraction=65
-XX:+CMSScavengeBeforeRemark
-XX:+UseCMSInitiatingOccupancyOnly
-XX:ReservedCodeCacheSize=64m
-XX:-TraceClassUnloading
-ea
-Dsun.io.useCanonCaches=false

回答by Able Johnson

I had the same issue in IntelliJ in MAC.

我在 MAC 中的 IntelliJ 中遇到了同样的问题。

There is a build process heap size configuration in IntelliJ. You can find this setting in

IntelliJ 中有一个构建过程堆大小配置。您可以在

Preferences > Compiler > Build Process Heap Size

首选项 > 编译器 > 构建进程堆大小

Make sure the Xmx value(in the environment or VM options) is lower than the value in settings. If not either increase Build Process Heap Sizein IntelliJ settings or reduce Xmx value in VM options.

确保 Xmx 值(在环境或 VM 选项中)低于设置中的值。如果不是,要么在 IntelliJ 设置中增加构建进程堆大小,要么在 VM 选项中减少 Xmx 值。

By default Build Process Heap Sizewill be 700m.

默认情况下,构建进程堆大小将为 700m。

回答by CrazyCoder

Use Help | Edit Custom VM Options, change -Xmxvalue only to 2GBor whatever value you need, -Xmsvalue should be lower or the same. Note that too high heap can make GC pauses much longer.

使用帮助 | 编辑 Custom VM Options-Xmx仅将2GB值更改为或您需要的任何值,-Xms值应更低或相同。请注意,过高的堆会使 GC 暂停更长时间。

You problem may be not related to memory settings at all. The proper way of reporting performance issues is described in this document. You need to capture a CPU snapshot and submit it to JetBrains support or the issue tracker.

您的问题可能根本与内存设置无关。本文档描述了报告性能问题的正确方法。您需要捕获 CPU 快照并将其提交给 JetBrains 支持或问题跟踪器。