Configuring IntelliJ IDEA VM options

alexandra.rusina

The default VM options for IntelliJ IDEA may be not optimal when your project contains more than 10000 classes and developers often try to change the default options to minimize IntelliJ IDEA hangtime. But sometimes the changes make things even worse.
So, how to configure IntelliJ IDEA VM options optimally? That’s not so easy question to answer, since the configuration strongly depends on the project being developed.
However, it is a well-known fact that JetBrains “eats its own dog food” and uses IntelliJ IDEA for development of new IntelliJ IDEA versions. Therefore, we can recommend some settings that our developers use and explain the general memory policy.
1. -Xms = 32m (64m)
2. -Xmx = 256m
Please note that very big Xmx and Xms values are not so good. In this case, GarbageCollector has to work with a big part of memory at a time and causes considerable hang-ups. On the other hand, too small values can lead to the OutOfMemory exception. The specified values provide enough memory and at the same time the GarbageCollector works often but rather fast.
One more important thing is to pay attention to the memory indicator at the bottom-right corner of IntelliJ IDEA. If it shows that the memory in use is almost equal to the total memory available (let’s say 195m out of 220m), we recommend you to increase Xmx on 50m or so.
3. -XX:MaxPermSize=92m
This is a default value, and in most cases you don’t need to change it. You may increase it only if you get “OutOfMemoryError” in “PermGen space”.
4. -server
Some people find IntelliJ IDEA more responsive with this option. But it is not guaranteed.
5.   We don’t recommend to use the following options at all, since they are not very stable:
    -XX:+UseParallelGC
    -XX:+UseAdaptiveSizePolicy
    -XX:-UseConcMarkSweepGC

Technorati tags: ,
Comments below can no longer be edited.

34 Responses to Configuring IntelliJ IDEA VM options

  1. Hassidi says:

    May 31, 2006

    I saw in the intellij.net website forum the followed: “-Dsun.awt.keepWorkingSetOnMinimize=true”.

    Is it safe? Is it usefull?

    I didn’t see it in your “not to use” parameters?

    Thanks.

  2. Alexandra Rusina says:

    May 31, 2006

    We don’t configure this option for IntelliJ IDEA. So, I can’t say whether it is actually useful or not.
    Probably, this link may help you somehow:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5043070

  3. Brad says:

    July 18, 2008

    Have the recommendations changed in the past couple of years or are these still the recommended JVM settings with 7.0.3?

  4. Michael Hunger says:

    August 6, 2008

    I finally boosted my IDEA to great performance again, just by buying a SSD drive.
    See:
    My IDE(A) is fast again

    Happy coding

    Michael

  5. Lahiru Gunathilake says:

    February 1, 2010

    Look, you haven’t mentioned that where do we have to do all of these changes.. why are you always missing basics and very simple stuff.. new Idea user will probably get lost with these instructions..

    You have to edit the idea.vmoptions file with those mentioned parameters.

    Lahiru

  6. On Boosting My IDE(A) – Jetbrains IntelliJ IDEA is fast again | Better Software Development says:

    March 6, 2010

    […] There were several articles talking about IDEA optimizations. Mostly settings and JVM startup params. 10 Tips by Hamlet d’Arcy IDEA Performance Tuning by J2EE blogger IDEA VM options from the JetBrains blog […]

  7. Mohammad Kamran says:

    March 16, 2010

    Is there any website having complete tutorial regarding idea.exe.vmoptions configuration for newbies in Java?

  8. Rob says:

    July 30, 2010

    @Mohammad – I find intellij to be pretty good out of the box these days (version 9). I’ve just reinstalled on a new machine and have set -server and -da out of habit, but it was working fine before I did that. The heap size settings were already sufficient for my needs (512m).

  9. Lato says:

    August 6, 2010

    1. -Xms = 32m (64m)
    2. -Xmx = 256m

    The definition above is confusing. Using these parameters in your vm, you have to define them like:

    -Xms64m -Xmx256m

  10. Carl says:

    September 7, 2010

    This tutorial is incomplete and outdated.

  11. jidea says:

    September 8, 2010

    For any one wondering where you should do the changes, It is in
    JetBrainsIntelliJ IDEA binidea.exe.vmoptions file.

  12. One Solution for IntelliJ IDEA Freezing « mikhail panchenko / blog says:

    October 8, 2010

    […] codebase, so 1GB suits us well. IntelliJ’s developers stated essentially the opposite here a few years back, but my experience does not correspond with their predictions. I’m guessing […]

  13. Craig Motell says:

    March 26, 2011

    “C:Program Files (x86)Javajdk1.6.0_21jrebinjava” -Xms128 -Xmx256 -Didea.launcher.port=7532 “-Didea.launcher.bin.path=C:Program Files (x86)JetBrainsIntelliJ IDEA Community Edition 10.0.2bin” -Dfile.encoding=windows-1250 -tetc…etcclasspath C:Program Files (x86)JetBrainsIntelliJ IDEA Community Edition 10.0.2libidea_rt.jar” com.intellij.rt.execution.application.AppMain

    Error occurred during initialization of VM
    Too small initial heap

    I have tweaked heap space in three locations:
    1) edit configuration (for my project) with VM parameters -Xms128m – Xmx256m and/or -Xms256m -Xmx512m

    2) settings (put maximum heap size 1024M)

    3) idea.exe.vmoptions (from 64m to 1024m) now at -Xms128m – Xms1012m

    When I run my program, the console shows only the vmopitons settings.
    But I’m still running out of heap space at the very start.

    Also when I run IntelliJ It tells me that I have memory left.

    Can you tell me if there is anything else I can try? And how the three settings relate?

    thank you

  14. yole says:

    March 28, 2011

    Craig,
    The correct syntax to use is -Xms128m rather than -Xms128. It looks like incorrect settings are specified in your run configuration settings.

  15. Ernst Bunders says:

    July 27, 2011

    There is a related issue to idea memory settings, that I would love to get an answer to. It is becomming slightly vexing to me.
    My vmsettings options are:
    -Xms128m
    -Xmx700m
    -XX:MaxPermSize=250m
    -XX:ReservedCodeCacheSize=64m

    And when I look at the lower right, idea tells me it’s using ‘159M of 620M’
    That would be nice, right?
    But my os process manager tells me a different story: 1.5GiB WTF!!!

    I am developing on a 4GiB machine, and usually my memory is full, thanks to idea. I don’t get this, and the weird thing is noone else seems to be troubled by this, i can’t find any comments about it.

    I am currently using ubuntu 11.4 and idea-IU-107.105, but the problem was there from the start, about a year ago.

    It’s not impossible to work, but is sure is annoying. If anything could be done, or if at least i could understand why this happens, I would be glad.

    regards,

    Ernst

  16. Damian Nowak says:

    September 15, 2011

    > when your project contains more than 10000 classes

    How to check the number of classes in IDEA?

  17. Vathanak says:

    September 18, 2011

    Hi,

    A blog said (I forget it) that if you increase the MaxPermSize over 500m, there may be the memory problem because garbage collector might take forever to do its task. I don’t know it’s true or not. If it’s true, can you decrease it to 500m or can you try to set the maximum garbage collector pause to (in the file idea.vmoptions) :

    -XX:MaxGCPauseMillis=10

    That means that java’s GC will take max 10ms to do his work.

    And use concurrent Mark-Sweep (CMS) Collector (But i’m not sure that this will help for latest version of IDEA)

    -XX:+UseConcMarkSweepGC

    Reference: http://stackoverflow.com/questions/4676604/how-to-improve-intellij-code-editor-speed

  18. Bjørn Chr says:

    September 27, 2011

    “However, it is a well-known fact that JetBrains “eats its own dog food” and uses IntelliJ IDEA for development of new IntelliJ IDEA versions.”

    Sounds like it could often become terrible confusing..

    • irvin says:

      April 28, 2016

      very good 哈哈

  19. Val says:

    October 14, 2011

    I used version 9.0.3 on my old XP
    Now I upgraded my machine with dual CPU and 3.16 GB
    And IntelliJ 10.5.2
    Previously I used -Xms128m -Xmx2048m -XX:MaxPermSize=250m -XX:ReservedCodeCacheSize=64m
    It was pretty slow. Memory consumed by Idea process was over 1gb

    Now I cannot run idea 10 with setting -Xmx2048m . It returns “too large” error.
    I changed to -Xmx1024m, but it is working extremely slow – number of hours to load a project.
    Please, advice.
    Thanks.

  20. RobM says:

    October 24, 2011

    This is some sort of slow-death torture.
    Idea 10.5.2 on Vista Business SP2. Administrator account and a personal account with administrator privs.
    The file and folder declined editing from my personal (with Administrator privs) account. But both say that “effective privileges” mean it’s editable. Finally turned off User Account Control and it permitted me to edit and save the file in place, but on changing back to my user account the file has reverted to some default setting:
    -Xms128m
    -Xmx512m
    -XX:MaxPermSize=250m
    -XX:ReservedCodeCacheSize=64m
    -ea
    Interesting to see that I can’t see line breaks in that string in the file in notepad, but pasted into here it breaks the lines? Nix line breaks in a windows config file???
    What a mess. Why are there so many magic doors to open to set these?

  21. RobM says:

    November 1, 2011

    Seems fixed now thanks to:
    http://www.pauldeden.com/2011/06/how-to-fix-permgen-memory-error-in.html

  22. RobM says:

    November 2, 2011

    This is the monkeyscript for the fix I’m using successfully in Intellij 10.5.2:

    From the intellij menu:
    “Run” – “Edit Configurations” –
    Expand “Grails” – “Grails:[projectname]” – “Grails” tab
    In the “VM Parameters” textbox, set the following:
    -XX:MaxPermSize=256M
    “Apply” and Ok your way out.
    That line was blank when I started. If it has something in it already you may need to discover what the correct delimiter is to add this bit. BTW, that line was cut and paste from my working intellij, so it should be right.

  23. RobM says:

    December 12, 2011

    This is the line currently in that config box (mentioned above) after some months of use and tweaking:
    -XX:MaxPermSize=128m -XX:PermSize=128m -Xms1024m -Xmx1024m -XX:-UseGCOverheadLimit

  24. David says:

    January 13, 2012

    Nice article but not actual navigation paths posted to direct the user as to where to apply the posted values such as MaxPermSize. :-S

  25. Sireon says:

    March 7, 2012

    “C:Program Files (x86)JetBrainsIntelliJ IDEA 10.5.4binidea.exe.vmoptions” if you use Windows 7.

    Hint:
    Make sure that you run the editor as administrator in order to be taken into account by IntelliJ Idea.

  26. Marc Jay says:

    June 22, 2012

    This article is 6 years old now, and still top in google search results. How about a new article jetbrains! It’s 2012.

  27. Stefan Reich says:

    October 13, 2012

    Hi all! I recommend this option for IntelliJ 11 in idea.exe.vmoptions: -XX:MinHeapFreeRatio=15

    This reduces memory usage drastically which leads to less swapping. The option means that only 15% of IntelliJ’s heap will be unused, not 40% as per default. I’m not seeing noticeable performance decreases by this.

    You could even go down to 10%…

  28. Mohsen says:

    November 21, 2012

    I can’t increase my intellij xmx more than 900 MiB.
    While I’m using 32 bit windows with 4GiB of RAM.
    How can I increase xmx to 2GiB?

  29. Michael Hasenstein says:

    December 8, 2012

    About complaints about the age of this article: It does not really matter, those options are generic Java runtime options. Nothing here is specific to Webstorm, which means you can leave out “webstorm” out of your Google searches for this topic and instead focus on “java”. You’ll find TONS of articles and forum posts regarding JRE parameters like Xms, Xmx, etc.

  30. Tony OHagan says:

    September 30, 2014

    Here’s a more recent post from JetBrains … Note that it mentions where to the the 64 bit settings that this article is lacking.

    https://intellij-support.jetbrains.com/entries/23395793-Configuring-JVM-options-and-platform-properties

  31. utkarsh says:

    September 5, 2015

    so what should be the idle xms for intellij idea projects if i want it to run smoothly

  32. Marc says:

    March 4, 2016

    Doesn’t work for me :/ Within a “large” project (it’s just TYPO3 and I can’t exclude all directories) the indexing process runs and runs and then I get the “increase memory..” window. I tried a lot of cases with Xmx and Xms, nothing works – and that I am paying for? I’m just looking for another IDE, PHPStorm seems to be not the best for me. This issue comes several times in different projects.

    16GB of RAM won’t fit on Ubuntu 64bit – i’m confused

  33. Shweta mantri says:

    February 20, 2018

    I added this to -XX:ReservedCodeCacheSize=250m in idea.vmoptions to help->edit my vm options but now my IntelliJ does not open at all. I need to get rid of that line from the vmoptions, how do i do it without it opening.

Subscribe

Subscribe for updates