The solution to modifying memory parameters in Idea under Mac computer does not work
Tags: jvm, idea, java, macos
Published: 2022-06-22 00:56:48

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e6xl0q0xzrjio4rcxnr2.png)
1.2 Then open idea.vmoptions under the bin, modify Xms, Xmx and save, restart idea.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ngdselj2cld3eo7bjn4h.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2tjodbl53friymca7pxd.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zr0sip2d51q6zon2cv9j.png)
**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h15v4yv933z9g821lj65.png)
You will see that the path of the idea startup loading configuration file is as follows:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awr9skx6tqp5rqczfr30.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/029jx8n4fi2cznjtlttr.png)
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
```
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kq5hag9m3f0rheyhp4kq.png)