Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I'm a beginner in Java, and I just started using Intellij as my 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.

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.

like image 542
김상기 Avatar asked Nov 02 '17 02:11

김상기


People also ask

How do you fix initial heap size set to a larger value than the maximum heap size?

To get rid of this error, the value of Xmx(maximum heap size) should always be greater than or equal to Xms(minimum heap size). Run the HelloWorld program with the value of Xms(minimum heap size) set to 1 gigabyte and Xmx(maximum heap size) set to 2 gigabytes.

How do I change my heap size in IntelliJ?

Open the Toolbox App, click the settings icon next to the relevant IDE instance, and select Settings. On the instance settings tab, expand Configuration and specify the heap size in the Maximum heap size field.

What is initial heap size and maximum heap size?

Initial heap size is 1/64th of the computer's physical memory or reasonable minimum based on platform (whichever is larger) by default. The initial heap size can be overridden using -Xms. Maximum heap size is 1/4th of the computer's physical memory or 1 GB (whichever is smaller) by default.

What is the maximum heap size in IntelliJ?

Limits the maximum memory heap size that the JVM can allocate for running IntelliJ IDEA. The default value depends on the platform. If you are experiencing slowdowns, you may want to increase this value, for example, to set the value to 2048 megabytes, change this option to -Xmx2048m .


2 Answers

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.

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

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

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

like image 184
BrianC Avatar answered Oct 20 '22 20:10

BrianC


I had the same issue on Linux. The configuration file is found in ~/.IntelliJIdea2018.2/config/idea64.vmoptions The 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 -Xms value is higher than the -Xmx Here is my working config for ubuntu 18.04 with 8GB RAM

# 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
like image 41
Mijo Avatar answered Oct 20 '22 20:10

Mijo