7 Tips to Speed Up Eclipse

About a month ago, I blogged about my love/hate relationship with Eclipse. I was asked by a few people to share my tips on how I was able to speed it up so here we go… As a side note, this article is not about comparing IDEs, please refrain from displaying your hate for the IDE or your preference for another…  This post is just about optimizations that help Eclipse run faster for those who use it. I’ve described each tip for Windows, Linux and MacOS users. Once you have gone through all the optimization tips, Eclipse should start within 10 seconds and run much smoother than before.

[edit]: most of those tips will speed up your Eclipse experience, not just the startup time. Classes will open faster, jumping from one definition to another will be faster. Viewing method javadocs will be faster… Unfortunately, none of that can be timed precisely so there is no specific benchmark about the actual speed gains for each tip.

Note: I assume that you already have an SSD and at least 8Gb of RAM. If not, look no further for performance boosts…

Tip 1 : Always run the latest JDK and Eclipse.

More often than not, every new JDK and Eclipse version includes fixes and optimizations from previous versions. Make sure that you are using the 64 bits version of Eclipse and of the Oracle JDK. For any web development, you will want to use Eclipse for Java EE and not Eclipse for Java.

Oracle JDK : http://www.oracle.com/technetwork/java/javase/downloads
Eclipse : https://eclipse.org/downloads/

Place Eclipse and your code on your SSD.

Time to launch Eclipse.

Tip 2 : Tune Eclipse Preferences

  • General > Startup and Shutdown : remove all plugins activated on startup
  • General > Editors > Text Editors > Spelling : Disable spell checking
  • General > Validation > Suspend all
  • Window > Customize Perspective > Remove stuff you don’t use or want (shortcut keys are your friends), same for Menu Visibility (how many times have you printed a source file…)
  • Install/Update > Automatic Updates > Uncheck “Automatically find new updates”
  • General > Appearance > Uncheck Enable Animations
  • Stay with the default theme. Unfortunately, anything else makes it really laggy and slow.

I personally turn off autosuggestions so that they don’t slow down my typing. Instead, I manually trigger the auto suggestions using Ctrl+Space when needed. This is done through:

  • Java > Editor > Content Assist > disable Enable Auto Activation. Advanced > Remove all unwanted kinds

Tip 3 : Keep your JDK on a RAM Disk

A RAM disk is a virtual disk or hard drive that is stored into the computer’s memory. It boosts the I/O performance on anything that is on it. Creating a RAM disk uses your RAM even though it just appears as a drive on the computer. Because the memory used will be reserved for the disk and become unavailable for other programs, we will only be putting the JDK on there. 300MB will be enough.

Warning: Don’t put anything permanent on the RAM Disk we will create as it will be erased/recreated at each reboot.

Step by Step for Linux users:

Everything is described here already

Step by Step for Mac Users:

The RAM Disk is created with the diskutil tool:

1. Create a new batch file, for example: ~/tools/batch/ramdisk.sh
Replace x, y, and z with the JDK version you have installed on disk:

#!/bin/bash 
diskutil erasevolume HFS+ 'JDK RAMDISK' `hdiutil attach -nomount ram://614400`
cp -r  /Library/Java/JavaVirtualMachines/jdk1.x.y_z.jdk /Volumes/JDKRAMDISK

(Note that diskutil expects the number of 512 bytes sectors to be allocated: for 300MB, 300 * 1024 ^ 2 / 512 = 614400)

2. Save your file and make it executable:

chmod 755 ~/tools/batch/ramdisk.sh

Now run ramdisk.sh to create the Ram Disk:

$ ramdisk.sh 
Started erase on disk4
Unmounting disk
Erasing
Initialized /dev/rdisk4 as a 300 MB case-insensitive HFS Plus volume
Mounting disk
Finished erase on disk4 JDKRAMDISK

You should now see in Finder the new device called JDKRAMDISK containing your JDK. You can remove the RAM Disk and free its memory by clicking on the Eject button:

Note that if you follow this tip, you will always need to have the RAM Disk in order to launch Eclipse (otherwise you will see the error “A Java Runtime … must be available in order to run Eclipse”). You can configure your system to run the ramdisk.sh script automatically upon startup using Automator or using a launchtl daemon.

Step by Step for Windows Users:

1. Download and install the utility called imdisk 

2. Create a new batch file, for example: C:/tools/batch/ramdisk.bat
Replace x, y, and z with the JDK version you have installed on disk:

@echo Placing JDK on Virtual Disk N:/
@echo off
sc config imdisk start= auto
net start imdisk
imdisk -a -t vm -s 300m -m n:
format n: /q /Y
call xcopy C:\<path_jdk>\jdk1.x.y_z N:\jdk1.x.y_z\ /S /E /Y /Q
label n: JDK RAMDISK

By running ramdisk.bat, you will have created a new disk N: labeled “JDK RAMDISK” that will contain your JDK.

3. Make sure the file is run as an Administrator. Right click on the file, go into Properties and check Run as Administrator.

Note that if you follow this tip, you will always need to have the RAM Disk in order to launch Eclipse (otherwise you will see the error “A Java Runtime … must be available in order to run Eclipse”). You can configure your system to run the ramdisk.bat script automatically by placing the script into your Startup folder.

In order for Tip 3 to work, you will need to add the -vm setting in eclipse.ini (see next section)

Tip 4 : Tweak your eclipse.ini

This is one of the most confusing areas of Eclipse optimizations. There are thousands of online articles preaching different configurations… I’ll just describe the way I tweaked my options and add more to the existing confusion 🙂

Location your eclipse.ini file:
Windows/Linux: located in $ECLIPSE_HOME
MacOS: located in $ECLIPSE_HOME/Eclipse.app/Contents/MacOS

Understanding what’s going on…

Eclipse.ini contains 2 types of properties: properties relative to the Eclipse application and properties relative to the JVM. Those options are different depending upon your version of JDK or Eclipse. Here is the most up-to-date list I was able to find online.

To understand those options require just a bit of vocabulary on Oracle’s JVM. Basically, the JVM memory is divided into multiple memory pools where objects reside with time:

  • The Eden Space (heap) provides the memory for most initial objects. The Garbage Collector passes often through this space containing objects of “young generation”. It removes any objects that hasn’t been used for a while. 
  • The Survivor Space (heap) contains the objects that have not been destroyed after 2-3 passes of the GC in the Eden Space. They are still part of the “young generation” but have moved to a much safer place where they have less chances of being destroyed: the Garbage Collector passes much less often there (it assumes from past experience that objects are used more frequently).
  • The Tenured Space (heap) contains the objects that have been in the Survivor Space for a while.
  • The Permanent Generation (non-heap) contains all the metadata about of the JVM, such as the class properties, methods, enums, etc. Because that data can be shared accross multiple JVMs, the permanent generation has read-only and read-write areas.
  • The Code Cache (non-heap) provides the memory used for compiling and storing code.

In case you are interested, Oracle wrote a great article about garbage collection tuning, detailing all those spaces and roles

The sizes for all those memory pools can be tweaked in eclipse.ini. I have 16Gb of RAM, but these settings will work fine with 8Gb of RAM. 


use the JDK stored on the RAM Disk (use the version according to what you did in Step 3):

-vm
/Volumes/JDKRAMDISK/jdk1.x.y_z.jdk/Contents/Home/
-vm
N:/jdk1.x.y_z/bin

disable bytecode verification (risky)

-Xverify:none 

This basically skips the verification of class files (described in http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.10), meaning that the JVM won’t be able to detect the authenticity of the class files you are using. This poses a security threat if the compiled files have been altered. Use at your own risk. (I use that option for hobby projects but not at work)


turn on performance compiler optimizations

-XX:+AggressiveOpts

increase permanent generation space (where new objects are allocated)

-XX:PermSize=512m
-XX:MaxPermSize=512m

increase min and max heap sizes (which includes young and tenured generations)

-Xms2048m
-Xmx2048m

increase heap size for the young generation

-Xmn512m

set stack size for each thread

-Xss2m

tweak garbage collection

-XX:+UseParallelOldGC

And finally, here are some other options that you may see online… Personally I didn’t notice much of a boost by using any of them so I’m just stating them for info. You can look at the doc reference to know what they correspond to and then play with them:

-XX:MaxGCPauseMillis=10
-XX:+UseG1GC
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+CMSIncrementalPacing
-XX:+UseFastAccessorMethods
-server

Finally, remove all the duplicates as well as launcher.XXMaxPermSize which is useless with the option XX:MaxPermSize.

Tip 5: Get your anti-virus outta here

If you have an anti-virus, make sure that it doesn’t interfere with your code folders. Add the JDK folder, the Eclipse folder, your .m2/jar repositories, and your code folders to the antivirus whitelist.

Tip 6: Keep SVN and GIT out of Eclipse

This is really a matter of personal preference. Some will like the Eclipse integration with the collaborative team tools. Personnally I find them slow, I’d rather have Eclipse concentrate on the dev task than try to do too many things at once… I’m also a sucker for the SVN/GIT CLIs… Anyways,  I removed the integration with Eclipse and found it much more responsive.

Tip 7: Use your keyboard

One of the perks of Eclipse is the trumendous amount of keyboard shortcuts it offers. You can remap them if you are used to other schemes. I usually remap my debugging keys for ex. so that they match the ones in VIsual Studio &  Chrome Dev Env. Take some time to learn them. The less your hands leave your keyboard, the faster your Eclipse experience will be!

I won’t go into details about which shortcuts to know but you can easily find that information online. Just thinking about it, a few must-know shortcuts come to mind:

Ctrl+Shift+R : jump to resource
Ctrl+Shift+T : jump to class
Ctrl+. : jump to next error
Ctrl+Shift+G : search for references
Ctrl+Shift+P : select matching bracket
Alt+Arrows : go forward / backwards
Ctrl+Space : autocomplete
Ctrl+Shift+F : format source
Ctrl+Shift+O : organize imports
Ctrl+D : delete line
etc.

This pretty much wraps it up! Without comparing Eclipse to any other tool out there, I find that it can be a very powerful and fast tool to write java code with.

If you have any other tips, I’d love to hear about them!

21 thoughts on “7 Tips to Speed Up Eclipse

  1. Great tips.

    Personnaly, my two favorite shortcuts are :
    – Ctrl+O to jump to any field/function in the current file.
    – Ctrl+Alt+R while being on any field/function to rename it.

    Also, I don’t like GIT inside Eclipse. Kinda not work like I want, or maybe I don’t use it the right way.

  2. Some guys talked to me that deleting plugins/*.jp*.*, features/*.jp*.* plugins is useful when you don’t use JPA features.
    Thank you for your tips.

  3. Thanks for the tips. Small correction: Validation is a root category, not a subcategory of General (at least in Luna). Also, here’s another tip that has made Eclipse more bearable: remap Ctrl+Tab to the “Next Editor” command. This will allow you to switch back and forth between two documents by using Ctrl-Tabbing, similar to the behavior of some other popular editors.

  4. One more thing: instead of using the -vm option, I simply copy the JDK ‘bin’ directory to my virtual disk in my startup script and then create a symlink/junction to this directory inside the JDK directory. The benefits are (1) you only consume 3MB of RAM instead of 300MB, and (2) any other application that relies on JDK ‘bin’ will also benefit.

  5. Nicolas, a really great and useful post! I am personally interested in getting the most out of Eclipse’s speed and will give a talk at EclipseCon Europe this year about that: https://www.eclipsecon.org/europe2015/session/boosting-performance-your-eclipse-ide
    Your post was a valuable, if not the most valuable, source of inspiration. I will give reference to it on my slides.

    I recognized a minor issue: The option “-XX:+CMSIncrementalPacing” you are mentioning is ineffective, it is a setting for the Concurrent Mark and Sweep GC. But you are activating exlicitly another GC, thus CMS is not active.
    Actually there is the next error, you both mention “-XX:+UseParallelOldGC” and “-XX:+UseG1GC”. These are two different GCs and the JVM won’t start with both options.
    When using G1GC it is not recommended to set the Young Generation size with -Xmn. There is a good article about benchmarking different GCs: http://blog.mgm-tp.com/2013/12/benchmarking-g1-and-other-java-7-garbage-collectors/
    Last issue: The option “-XX:MaxGCPauseMillis=10” is mentioned twice.

    Personally it does not work on my Mac to move the full JRE to RamDisk and reference it with -vm. The JVM refuses to start, it does not find a dylib then. Therefore I only moved rt.jar to RAM and make a symbolic link to its representation on RAM Disk. It is of course useful to store more on the RAM Disk: Read-only files (esp. Plugin Jars) and temporary data (Local History, JDT Index, Build output folders). The problem with Build Output is that you have to use symbolic links and create them with scripts when working in a team, since other team members might rely on the fact that the output folder is local to the project location.

    Best wishes,
    ~Karsten

  6. Favorite Eclipse shortcut, especially for very large projects.
    shift+cmd+r = Open Resource (file finder , with wildcards!)

    2nd fav , especially for very large files
    cmd+o = Open method list , do it again and you get inherited members

  7. Great tips!
    about: Tip 6: Keep SVN and GIT out of Eclipse
    I agree. (I use git command line).
    How do I remove it? (i see it’s marking changes… so it’s somehow activated, maybe by me a while ago)

  8. Saving of the settings file was taking ages. Apparently this was caused by xml validation settings.
    Probably the setting “Check full XML schema conformance” under XML > XML Schema Files

  9. Nicolas, thank you for taking your time to write a nice and useful tutorial. I’m trying to set up eclipse to get the jdk from the ramdisk, but I get an error when trying to launch it: “To open eclipse you need to install the legacy Java SE 6 runtime.”. I applied the correct path in eclipse.ini and checked if the files are in there, everything should work, but somehow it doesn’t. I’m on a macbook running el capitan. Any thoughts? Thank you!

  10. I find the post extremely interesting and I would like to ask a question:
    if I have a workstation with a really fast SSD drive where I install everything, i.e. Eclipse and JDK (in my case also python since use python), do you think that the process you have proposed will still provide some gain in performance?

    Thanks you

    Luca

  11. Nicolas, thank u so much for the awesome tips.

    Does anyone know how to make “class members” disapear in “Project Explorer” view ?

    Thanks!

  12. Thank you! I’ve been trying to figure out how to make Eclipse tolerable, but since I’m so new to the environment, all of the posts I read were -unhelpful-! I didn’t do every step (failed on the 8GB thing, for starters), but it now loads in about 30 seconds as compared to 5 minutes. Thank you!

  13. Great article!

    I was annoyed by poor eclipse scrolling performance in MacOS Sierra, found several posts in different forums blaming Cocoa implementation and saying there was no solution, but applying just your 2nd tip improved response time and made my IDE usable.

    Thank you!

Comments are closed.