97

I'm using intelliJ for Scala development and got 8 GB of new RAM last week, so I thought: time to use it. I checked my task manager and found intelliJ using ~250mb. From eclipse I knew that tweaking JVM options helped a lot in improving speed, so I googled ...

and found this one for OS X I couldn't find the JVM option immediately, so I started tweaking Xmx. At 1 GB, I realized it doesn't start any more. I checked the intelliJ java version, found it's outdated and 32bit.

So in order to use your current JDK and 64 bit you have to change your link to from:

IntelliJ IDEA Community Edition 10.0.2\bin\idea.exe

to

IntelliJ IDEA Community Edition 10.0.2\bin\idea.BAT

and adjust "Start in"

The bat looks for JDK_HOME and uses 64bit now.

My current VM Options, which are located in

...\IntelliJ IDEA Community Edition 10.0.2\bin\idea.exe.vmoptions

are

-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-ea
-server
-XX:+DoEscapeAnalysis
-XX:+UseCompressedOops
-XX:+UnlockExperimentalVMOptions
-XX:+UseParallelGC

Instead of -XX:+UseParallelGC, you can use -XX:+UseConcMarkSweepGC, which is

the accepted choice for desktop apps, but I have changed to the throughput collector recently. because with a fast machine and a small enough heap, you have quick pauses, more throughput and no issues with fragmentation (ijuma. #scala)

Changes:

-XX:+UseConcMarkSweepGC //removed
// removed, because not needed with the lastest JVM.
    -XX:+UnlockExperimentalVMOptions
    -XX:+DoEscapeAnalysis
    -XX:+UseCompressedOops

I'll stick to these options for now. I would really like to know your experience with it.

Which options work best for you? How do I hide this cmd window while running intelliJ through the .bat? :)

By the way, here's another link for tuning intelliJ. Basically it says on p.20/21 to turn off windows restore and antivirus for system dirs.

Another way to speed up intelliJ is to put intellij system folder on ramdrive (thanks OlegYch|h).

from idea.properties 
idea.system.path=${idea.home}/.IntelliJIdea/system

See Superuser for Win 7 64bit RAM Drive or this one. 1 GB seems fine for me.

Another hint a friend gave me is to exclude the project directories from your antivirus (scan on access)

There are similar posts regarding tuning Eclipse:

Community
  • 1
  • 1
Stefan K.
  • 7,701
  • 6
  • 52
  • 64
  • 6
    If the 64 bit version is run, the VM options are going to be read from `idea64.exe.vmoptions` – Arnaud P Jul 11 '13 at 03:24
  • I added a similar question, but for a 32-bit OS (Windows 7) and 3 GB RAM: [IntelliJ IDEA 13.1 - how to prevent low memory problems on a 32-bit OS (Win 7) with 3GB RAM](http://stackoverflow.com/questions/28026291/intellij-idea-13-1-how-to-prevent-low-memory-problems-on-a-32-bit-os-win-7-w) – krm Jan 19 '15 at 15:52
  • Why not run "idea64.exe" directly, instead of through the .bat file? (at least there is idea64.exe in IntelliJ idea 11? – jbarrameda Jun 11 '15 at 18:44

12 Answers12

35

This combination works great on my Intellij13 running in Mavericks:

Updated Jul 18, 2017:

# custom IntelliJ IDEA VM options

-ea
-server
-Xms2G
-Xmx4096M
-Xss2m
-XX:MaxMetaspaceSize=2G
-XX:ReservedCodeCacheSize=1G
-XX:MetaspaceSize=512m
-XX:+UseConcMarkSweepGC
-XX:+DoEscapeAnalysis
-XX:SoftRefLRUPolicyMSPerMB=50
-XX:+UnlockExperimentalVMOptions
-Djava.net.preferIPv4Stack=true
-Dsun.io.useCanonCaches=false
-XX:LargePageSizeInBytes=256m
-XX:+UseCodeCacheFlushing
-XX:ParallelGCThreads=8
-XX:+DisableExplicitGC
-XX:+ExplicitGCInvokesConcurrent
-XX:+PrintGCDetails
-XX:+PrintFlagsFinal
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:CMSInitiatingOccupancyFraction=60
-XX:+CMSClassUnloadingEnabled
-XX:+CMSParallelRemarkEnabled
-XX:+UseAdaptiveGCBoundary
-XX:+UseSplitVerifier
-XX:CompileThreshold=10000
-XX:+OptimizeStringConcat
-XX:+UseStringCache
-XX:+UseFastAccessorMethods
-XX:+UnlockDiagnosticVMOptions
-XX:+HeapDumpOnOutOfMemoryError
-XX:+UseCompressedOops
-XX:-OmitStackTraceInFastThrow
-Dawt.useSystemAAFontSettings=lcd

-Dsun.java2d.renderer=sun.java2d.marlin.MarlinRenderingEngine

I keep this setting updated at https://github.com/adben/config/blob/master/idea64.vmoptions

kross
  • 3,627
  • 2
  • 32
  • 60
adben
  • 596
  • 4
  • 7
  • 3
    you have plent of duplications in there – vach Dec 02 '14 at 06:41
  • 3
    be careful with this one `-XX:+UseCompressedStrings` , out of all on your list, this broke it for me, the rest worked. – blamb Mar 03 '15 at 03:35
  • 2
    Thanks @adben, it's greatly improved IJ on my PC. But I had to remove `MaxMetaspaceSize`, `MetaspaceSize`, `UseCompressedStrings` because they are not supported in IJ 14 on linux x86_64. `UseCompressedOops` ddin't work for me either. Hint: run IJ from command line to see error messages, on linux it's `idea.sh` – Mixaz Apr 20 '15 at 22:48
  • 1
    -XX:+UseCompressedStrings broke it for me too on Win8 x64 and IDEA 64-bit version. Everything else seems okay. – minorgod Dec 16 '16 at 17:08
  • To edit this file in the first place, simply press **Ctrl+Shift+A** for the Find Action popup and type "**Edit Custom VM Options**". It will automatically create the correct file for your machine that you can edit. – Kevin Cooper Apr 29 '17 at 19:27
  • # -XX:+UseStringCache # -XX:+UseFastAccessorMethods # -XX:+UseSplitVerifier These dont work with 2021 version. – Asiri Liyana Arachchi Jun 01 '21 at 03:40
31

For me switching to SSD-drive improved performance a lot (especially for large projects).

Yann Cébron
  • 2,042
  • 1
  • 17
  • 14
23

Some time ago I was looking for the ways to speedup my project's compilation and that is result. This is not for IntelliJ IDEA itself but will help a lot when (re)building a big projects and, I guess, it will work with any other IDEs too. Also, I described Linux approach, but I'm sure Windows have it's own RAM-disk implementations.

The easiest way to speedup compilation is to move compilation output to RAM disk.

RAM disk setup

Open fstab

$ sudo gedit /etc/fstab

(instead of gedit you can use vi or whatever you like)

Set up RAM disk mount point

I'm using RAM disks in several places in my system, and one of them is /tmp, so I'll just put my compile output there:

tmpfs /var/tmp tmpfs defaults 0 0

In this case your filesystem size will not be bounded, but it's ok, my /tmp size right now is 73MB. But if you afraid that RAM disk size will become too big - you can limit it's size, e.g.:

tmpfs /var/tmp tmpfs defaults,size=512M 0 0

Project setup

In IntelliJ IDEA, open Project Structure (Ctrl+Alt+Shift+S by default), then go to Project - 'Project compiler output' and move it to RAM disk mount point:

/tmp/projectName/out

(I've added projectName folder in order to find it easily if I need to get there or will work with several projects at same time)

Then, go to Modules, and in all your modules go to Paths and select 'Inherit project compile output path' or, if you want to use custom compile output path, modify 'Output path' and 'Test output path' the way you did it to project compiler output before.

That's all, folks!

P.S. A few numbers: time of my current project compilation in different cases (approx):

HDD:     80s
SSD:     30s
SSD+RAM: 20s

P.P.S. If you use SSD disk, besides compilation speedup you will reduce write operations on your disk, so it will also help your SSD to live happily ever after ;)

uncle Lem
  • 4,954
  • 8
  • 33
  • 53
  • Ram solution is great !! not only for performance but also protect SSD life time .thanks! – Mojtaba Asgari Dec 17 '15 at 06:28
  • I moved my `caches` and `index`folders via symbolic link to a RAM disk, [Intellij IDEA cache in RAM Drive](http://sheroz.com/pages/blog/improving-development-performance-moving-intellij-idea-cache-ramdisk.html) suggests another way to do it without symbolic links, however it would require a larger RAM disk because you can't specify only the caches and index folders that way. Needless to say, any search/lookup/clicking a symbol is instant or almost-instant now – ycomp May 29 '16 at 17:44
  • How to do this on windows 10? – Gaurav Apr 02 '18 at 09:59
  • @ycomp could you please elaborate on how to do that? – SergioLeone Jun 13 '19 at 09:49
  • I can't remember specifically, but it's probably more trouble than it's worth. Although it was wicked fast. I can't remember if there were any specific problems associated with doing that.. I stopped doing it once I migrated to another PC – ycomp Jun 13 '19 at 13:03
  • Here I've answered my own question on how I have achieved that - https://stackoverflow.com/questions/56579056/moving-intellij-idea-caches-index-directories-to-ram/56608390#56608390 – SergioLeone Jun 15 '19 at 07:41
20

Regarding:

How do I hide this cmd window while running intelliJ through the .bat?

Use the 'start' command and javaw.exe together, so, if you have:

SET JAVA_EXE=%IDEA_JDK%\jre\bin\java.exe
...
"%JAVA_EXE%" %JVM_ARGS% -cp "%CLASS_PATH%" %IDEA_MAIN_CLASS_NAME% %*

change it to:

SET JAVA_EXE=%IDEA_JDK%\jre\bin\javaw.exe
...
start "Intellij IDEA" /b "%JAVA_EXE%" %JVM_ARGS% -cp "%CLASS_PATH%" %IDEA_MAIN_CLASS_NAME% %*
Dilum Ranatunga
  • 13,254
  • 3
  • 41
  • 52
19

The most useful thing you can do for IntelliJ is to have a lot of free memory for disk caching. IntelliJ saves alot of its processing work in cached files. This works well if you have plenty of free memory, but if your disk cache is limited, you will see regular, long lasting pauses.

I would suggest -XX:+UseConcMarkSweepGC rather than G1.

I also work local copies of files to minimise file access delay.

BTW: For the project I am on, I noticed the difference between working on a machine with 24 GB and one with 48 GB, even though the max heap is set to 2 GB ;)

AdrieanKhisbe
  • 3,899
  • 8
  • 37
  • 45
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 5
    For me, the most important realisation is that when it pauses, its not due to GC, but rather having to re-read data off disk. – Peter Lawrey Apr 13 '11 at 15:44
  • 4
    The diff between a 48GB machine and a 24GB machine is likely due to filesystem /OS -level caching using the extra ram. – cdeszaq May 16 '13 at 15:43
  • [Here is a great tutorial](https://serpro69.medium.com/boosting-performance-of-intellij-idea-and-the-rest-of-jetbrains-ides-cd34952bb978) for creating an in-memory cache for Intellij as well as other speed-ups – ecoe Jan 02 '21 at 03:39
  • @ecoe Useful. I have found lots of memory and an SSD makes a big difference, even on a Raspberry PI 4 ;) – Peter Lawrey Jan 04 '21 at 16:02
4

I've done some experimenting, and found that to decrease GC pauses the following combination works best: -XX:+UseConcMarkSweepGC -XX:SoftRefLRUPolicyMSPerMB=50.

I'd also not make the heap too large, 512 or even smaller is OK for me. Otherwise when it becomes full the GC will have to walk it all which takes some time.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
Peter Gromov
  • 17,615
  • 7
  • 49
  • 35
2

You can find good tips here. For example, the speed of switching from IDEA to another app and vice versa was significantly improved after turning the feature "Turn off Synchronize Files" off.

http://hamletdarcy.blogspot.com/2008/02/10-tips-to-increase-intellij-idea.html

OJ278
  • 29
  • 1
2

Not sure why it has not been mentioned yet - you can enable Power Save mode, which turns off many IJ background activities, including Files Synchronization. Some articles says that it is possible to disable Files Sync in project structure options (like the article in answer by @OJ278), but I was not able to find this option in IJ 14, but Power Save mode seems to disable it.

I have a quite large code base (AOSP source code), so HD activity due to background files synchronization is annoying...

Mixaz
  • 4,068
  • 1
  • 29
  • 55
2

The answer provided by adben is very helpful for improving the performance in my machine. Though I slightly overrided it after reading a Dzone article,

-server
-Xms2g
-Xmx2g
-XX:NewRatio=3
-Xss16m
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
-XX:ReservedCodeCacheSize=240m
-XX:+AlwaysPreTouch
-XX:+TieredCompilation
-XX:+UseCompressedOops
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djsse.enableSNIExtension=false
-ea

They improved the performance of large projects by using the above configuration and works flawlessly for our projects too. Lastly, I disabled all the plugins I won't use and that improves the things as well.

Reference: https://dzone.com/articles/the-one-and-only-reason-to-customize-intellij-idea

Arefe
  • 11,321
  • 18
  • 114
  • 168
1

You can use the intellij's optimizer plugin:

https://zeroturnaround.com/free/optimizer-for-intellij-idea/

With the plugin you can:

  • Automatic tune virtual machine options
  • Disable class verification
  • Clean up system caches
  • Configure external build tools
  • Validate the latest Oracle JDK
  • Skip build and redeploy
iberck
  • 2,372
  • 5
  • 31
  • 41
1

Made a small write up on this topic on medium: https://medium.com/@sergio.igwt/boosting-performance-of-intellij-idea-and-the-rest-of-jetbrains-ides-cd34952bb978

SergioLeone
  • 734
  • 1
  • 10
  • 24
0

I used this combination and it's working fine in my environment

-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1
-XX:SurvivorRatio=8
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:+CMSParallelRemarkEnabled
-XX:CMSInitiatingOccupancyFraction=65
-XX:+CMSScavengeBeforeRemark
-XX:+UseCMSInitiatingOccupancyOnly
-XX:ReservedCodeCacheSize=64m
-XX:-TraceClassUnloading
-ea
-Dsun.io.useCanonCaches=false
Yasir Shabbir Choudhary
  • 2,458
  • 2
  • 27
  • 31