How to reduce memory consumption of idea

How to reduce memory consumption of idea

Tags: idea memory memory leak exception

When I developed with Intellij idea recently, I often encountered that the memory was full, resulting in abnormal freezes. At first I always thought it was my program's memory leak. Later, I found that even if I didn't start my own project, it was just a simple development, and there would still be memory usage. full or even overflowing.

Finally, I can't stand it anymore. I searched relevant articles on major technical websites, and they all said that the memory used can be increased by modifying the default vm configuration file of Intellij idea. For example, change the idea.exe.vmoptions file in the bin directory by

-server
-Xms128m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=150m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50

change into

-server
-Xms128m
-Xmx1024m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=150m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50

Of course, this requires you to have enough memory, but the actual situation proves (if your system is 64bit, there will be idea.exe and idea64.exe in the bin directory after installation, and the shortcut points to idea.exe by default), If the default 512m is modified, the first startup after modification will indeed take effect, but after startup, it will be automatically replaced with the previous configuration. I have tried many times (including reinstalling Intellij idea), but the problem is the same. I tried to start the 64bit idea64.exe, and found that the default memory was 750m, which was changed to a larger one. After starting it again, it was found that it was still normal, and it would not be replaced and restored to 750m. After several attempts, I decided to point the shortcut to idea64.exe. Finally solved my problem.

Of course, running for a long time will still consume more and more memory, but at least if you open Intellij idea for a whole day, there will be no memory overflow and suspended animation.

Another point to mention here is that idea64.exe must not only require the system to be 64bit, but also install 64bit jdk, so that it can be used normally. As for the 32bit system, when the memory is full and overflows, just You can still try to modify the content of the above prompt (remember that the company seems to be a 32bit system, and the memory is not often full), personal guess, maybe Intellij idea detects that the system is 64bit, it is recommended to install 64bit jdk, and then use 64bit Intellij idea is guided to start, but it is only a guess. Due to the limited English level, many articles are not in the mood to read carefully. It is not clear the specific reason, or the effect of Intellij idea is like this. If you know the deeper reasons and avoidance plan, restore advice.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324460825&siteId=291194637