From http://tomaszdziurko.pl/2015/11/1-and-the-only-one-to-customize-intellij-idea-memory-settings/ Note: Site no longer active.
Give more memory to IDEA and it will perform better. No big surprise, but some recommendations based on 3 different approaches. I now use the ‘Balanced’, summarized below. More memory without starving everything else on the machine.
2GB for Xmx and 2GB for Xms, more balanced approach to the memory consumption
For Mac, it’s in ~/Library/Preferences/IntelliJIdea15/idea.vmoptions.
For Windows, it’s in Program Files (x86)/JetBrains/bin/idea.exe.vmoptions.
Update: IntelliJ provides a shortcut from the Help menu to customize the VM Options. It will open or create the file in the OS specific location. On the Help menu, choose ‘Edit Custom VM Settings’.