Possible solutions for high memory and CPU of idea

Possible solutions for Idea leading to high memory consumption and high CPU occupancy:

1. Modify the VM options value corresponding to the Configurations configuration of the project

insert image description here

insert image description here

  • Xmx: The maximum value of Java Heap . The default value is 1/4 of the physical memory. The optimal setting value should depend on the size of the physical memory and other memory overheads in the computer.
  • Xms: The initial value of Java Heap , it is better to set -Xms and -Xmx to the same value for the JVM on the server side, and the JVM of the development test machine can keep the default value.
  • Xmn: The size of the Java Heap Young area. If you are not familiar with it, it is best to keep the default value.
  • Xss: The Stack size of each thread, it is best to keep the default value if you are not familiar with it;

vm optionsdea64.exe.vmoptionsOptimization (to avoid the problem of not optimizing the relevant configuration will be very stuck, and hot loading will be very slow), modify the files in the bin directory under Idea

-Xms1024m
-Xmx1024m
-XX:MaxMetaspaceSize=512m
-XX:MetaspaceSize=512m
-XX:InitialBootClassLoaderMetaspaceSize=64M
-XX:NewRatio=2
-XX:SurvivorRatio=8
-XX:MaxTenuringThreshold=6
-XX:+UseConcMarkSweepGC
-XX:CMSFullGCsBeforeCompaction=5
-XX:+CMSParallelRemarkEnabled
-XX:+CMSClassUnloadingEnabled
-Xss1024k
-XX:+DisableExplicitGC
-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses
-XX:ReservedCodeCacheSize=240m
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-Xloggc:D:/temp/gclog/idea.gc.log
-XX:+PrintHeapAtGC

2. Use the plugin choose runtime

ideaThe essential reason for the lag is that the running jreenvironment is different from the project's compilation environment.
For example, idea2019the version already uses its own packaged jre11version by default, and my project uses jdk1.8the version. The old version of the idea itself Switch Boot SDKcan be switched through functions, but the new version is no longer To provide this function, you need to use the idea plugin –choose runtime

Download the idea pluginChoose Runtiome
insert image description here

Double-click shiftglobal search, enter choose runtime, and then double-click to open . After
insert image description here
clicking install
insert image description here
successfully, restart idea. Double-click shift to global search choose runtime, and you can see that it has been enabled.
insert image description here
This solution comes from Baidu- Little Pony Myles , which completely solves the serious memory consumption and CPU resource ratio of Idea . The problem

Guess you like

Origin blog.csdn.net/qq_40542534/article/details/115443254