The solution to modifying memory parameters in Idea under Mac computer does not work

keith5140

Keith

Posted on June 22, 2022

The solution to modifying memory parameters in Idea under Mac computer does not work

When using idea, if multiple projects are opened at the same time, the memory is often full, which leads to abnormal freezes, and sometimes prompts memory overflow. At this time, it can be improved by increasing the value of Xmx. But how should the Xmx value be adjusted? Why does someone modify the Xmx value but it doesn’t take effect? This article will explain in detail.

1.Ineffective method

Many of the methods found on the Internet to guide you to adjust Xmx are generally as follows:
1.1 Right-click on the application idea — display package contents:
Image description
1.2 Then open idea.vmoptions under the bin, modify Xms, Xmx and save, restart idea.
Image description
But there should still be many friends who found that this operation has no effect, the idea is still stuck, and the fan is still whirring.
1.3 How to check whether the setting takes effect

In fact, you can judge whether the setting takes effect by looking at the two numbers in the lower right corner of the idea, as shown in the figure:
Image description
Here 989 is the maximum available memory, Xmx (the idea itself should occupy a small part), and 862 is the used memory.
If this number is not displayed in your lower right corner, you can set it by clicking “Intellij IDEA” — “Preferences” — “Appearance” in the upper right corner,
Check “Show memory indicator”, ok to save.

Image description
2. Reasons for ineffectiveness
2.1 What is the reason for the modification not taking effect?
First of all, confirm whether you have restarted the idea. The restart requires you to close all the idea windows and then open the idea.
If you are sure that it does not take effect after restarting, then there is only one reason: the modified file is not the file that idea actually uses.
2.2 Find the correct configuration

If you want to know which configuration file your idea allows, you can find Contents — the idea executable file under MacOS and double-click to run it

Image description
You will see that the path of the idea startup loading configuration file is as follows:
Image description
The configuration file used by my idea is: /Users/rcm/Library/Preferences/IdeaIC2018.1/idea.vmoptions
2.3 Modify the correct configuration

By going to the folder command, you can directly find this file and modify it. After modifying and saving, restart the idea to take effect.
Image description
My modified configuration is as follows:

-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=1024m
-XX:+UseCompressedOops
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-Xverify:none

-XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof
Enter fullscreen mode Exit fullscreen mode

The three main parameters modified:

  • Xms1024m -Xmx2048m -XX:ReservedCodeCacheSize=1024m

3. A more convenient method
Of course, you can also set it up in an easier way:

Click Help — Edit Custom VM Options , modify it in the open file, and restart the idea after modification
Image description

💖 💪 🙅 🚩
keith5140
Keith

Posted on June 22, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related