intelliJ IDEA 性能优化
问题
最近做项目 IDEA 占用内存有 1G 多,使用的时候很卡顿。
方法一:
设置JVM的启动参数
找到安装目录下的 bin :
打开 idea.exe.vmoptions 文件, 修改-Xmx 的 值为2048m
打开 idea64.exe.vmoptions 文件, 修改-Xmx 的 值为2048m
打开idea.properties文件,找到idea.max.intellisense.filesize,默认是2500,改为25000(数值仅供参考,具体数值根据自己文件大小来定)。
将原始配置信息修改为:
-server
-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=480m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
参数作用解释:
-Xms1024m 设置初时的内存大小,提高Java程序的启动速度
-Xmx2048m 设置最大内存数,提高该值,可以减少内存Garage收集的频率,提高程序性能
-XX:ReservedCodeCacheSize=480m设置代码内存容量
-XX:+UseParNewGC 使用并行收集算法
-server 控制内存garage方式,这样你无需在花一到两分钟等待内存garage的收集
方法二:
菜单配置设置JVM的启动参数
也可以通过 Help - Edit Custom VM Options...
菜单设置配置,这样设置的话IntelliJ会优先使用这个地方的配置文件。
方法三:
关闭代码检查
IntelliJ的代码检测功能非常强大,但同时也占用了一些资源,可以将默认的除 Error之外的其他级别的检测都去掉。







方法四:
清空缓存并重建索引
在做完上述设置之后,最好通过点击 File -> Invalidate Caches / Restart...菜单,然后点击 Invalidate and Restart按钮清空并重建索引,然后重启。再次启动程序之后,会首先重建索引和缓存。
方法五:
将编译进程和Maven的堆值设置大一些,见下图:

