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 over time:
Note: This assumes that you already have an SSD and at least 8Gb of RAM. If not, look no further and upgrade your hardware.
Tip 1 : Always run the latest JDK and Eclipse.
New JDK and Eclipse versions include fixes and optimizations from prior 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 repos on your SSD.
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. Anything else makes it 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, it will be erased/recreated at each reboot.
Linux users:
Everything is described here already
Mac Users:
The RAM Disk is created with the diskutil tool:
- 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:
1 | #!/bin/bash |
- Save your file and make it executable:
1 | chmod 755 ~/tools/batch/ramdisk.sh |
Now run ramdisk.sh
to create the RAM Disk:
1 | $ ramdisk.sh |
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:
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.
Windows Users:
Download and install the utility called imdisk
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 in the following script:
1 | @echo Placing JDK on Virtual Disk N:/ |
By running ramdisk.bat
, you will have created a new disk N: labeled “JDK RAMDISK” that will contain your JDK.
- Make sure the file is run as an Administrator. Right click on the file, go into Properties and check Run as Administrator.
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
Locate your eclipse.ini file:
- Windows/Linux:
$ECLIPSE_HOME
- MacOS:
$ECLIPSE_HOME/Eclipse.app/Contents/MacOS
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.
Oracle’s 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.
Oracle wrote a great article about garbage collection tuning.
The sizes for all those memory pools can be tweaked in eclipse.ini
. I currently have 16Gb of RAM, but these settings will work fine with 8Gb of RAM.
Settings tweaks:
- use the JDK stored on the RAM Disk (see Step 3):
1 | -vm |
- disable bytecode verification
1 | -Xverify:none |
This basically skips the verification of class files (described here) aka 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 so use at your own risk.
- turn on performance compiler optimizations
1 | -XX:+AggressiveOpts |
- increase permanent generation space
1 | -XX:PermSize=512m |
- increase min and max heap sizes
1 | -Xms2048m |
- increase heap size for the young generation
1 | -Xmn512m |
- set stack size for each thread
1 | -Xss2m |
- tweak garbage collection
1 | -XX:+UseParallelOldGC |
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. Personally I find they tend to make Eclipse slow and aren’t a good replacement for GIT/SVN CLIs.
Tip 7: Use your keyboard
Everything in Eclipse either has, or can be assigned a keyboard shortcut. Take some time to learn them and customize to your liking. I personally find that I can be more efficient when my hands don’t have to leave my keyboard.
A few important ones:
1 | Ctrl+Shift+R : jump to resource |
If you have any other tips, I’d love to hear about them!
Zappa says (November 27, 2014 at 11:03 pm):
kenu says (March 10, 2015 at 5:25 pm):
Tom says (August 18, 2015 at 3:42 am):
Tom says (August 18, 2015 at 4:08 am):
Karsten Thoms says (September 18, 2015 at 11:41 am):
al says (September 18, 2015 at 12:17 pm):
Michel van Leeuwen says (October 29, 2015 at 3:37 pm):
Jeroen says (November 24, 2015 at 9:19 pm):
robert says (January 2, 2016 at 2:09 pm):
Lakshman says (January 7, 2016 at 3:15 pm):
Luca says (April 13, 2016 at 12:03 pm):
Andre Paschoal says (October 17, 2016 at 12:34 pm):
Milind says (February 2, 2017 at 5:35 am):
Walison Moreira says (June 3, 2017 at 4:00 pm):
Kat says (July 15, 2017 at 3:25 pm):
Jief says (September 25, 2017 at 9:08 am):
il Barto says (October 7, 2017 at 4:05 pm):
Saharsh says (December 16, 2017 at 10:41 am):
Comments are now closed