7 Tips for accelerating eclipse
This article just focuses on how to make eclipse run faster. Each tip is detailed for Windows, Linux, and MacOS users. After using all the optimization techniques, eclipse should be able to start in 10 seconds and run smoother than before.
These techniques not only shorten eclipse startup time, but most of the techniques also improve the user experience. For example, open a class faster, jump from one definition to another, view Javadoc, and more. But these speeds cannot be measured in time, so there is no specific benchmark for the speed effects of each technique.
Tip: Suppose you have a solid-state drive and at least 8Gb of memory. If not, the performance gains may be modest.
Tip One: Run the latest version of JDK and Eclipse
In general, new versions of JDK and Eclipse will have performance optimizations. Make sure you are using 64-bit Eclipse and use Oracle's JDK. For network development, you need to use Eclipse for Java EE instead of Eclipse for Java.
- Oracle jdk:http://www.oracle.com/technetwork/java/javase/downloads
- eclipse:https://eclipse.org/downloads/
Place Eclipse and workspace on your SSD. Start Eclipse.
Tip Two: adjust Eclipse's preferences
- General > Startup and Shutdown: Removes all plugins loaded at startup.
- General > Editors > Text Editors > Spelling: Turn off spell checking.
- General > Validation > Tick "Suspend all validator".
- Window > Customize Perspective > Remove all content you don't use or want (use shortcut keys as much as possible), as well as the menu bar (how many times have you used the Print button on the menu bar?). )。
- Install/update > Automatic Updates > Uncheck "Automatically find new Updates and notify Me".
- General > Appearance > Uncheck "Enable animations".
- Use the default theme. Other topics may slow down.
I also turned off the automatic prompt myself so that I wouldn't be dragged down when I entered the code. The alternative is to use Ctrl+space to use manual prompts when needed. Can be completed by the following configuration: (Translator Note: Ctrl+space? The Chinese will not agree).
- Java > Editor > Content Assist > Disable Enable Auto Activation. Remove all unwanted content in advanced (not found in Eclipse 4.2.2).
Tip 3: Place the JDK on the memory disk (RAM disk)
The memory disk is used as a virtual disk or as a hard disk for the computer's memory. Used to speed up the IO performance of the software located therein. The RAM disk created in memory is like a hard disk on a computer. Because these memory is used as a hard disk, other programs will not be able to use these memory spaces. We just put the JDK there, and 300MB is enough.
Warning: Do not put any content permanently in the memory disk, each time you restart, the contents will disappear and re-create.
For Linux users:
This link is described in detail.
For Mac Users:
Create a memory disk using the Diskutil tool
1. Create a new script, for example: ~/tools/batch/ramdisk.sh
Replace the x, Y, and Z with your JDK version:
123 |
#!/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: The Diskutil expected parameter is an integer multiple of the 512-byte sector: For 300MB, it should be 300 * 1024 ^ 2/512 = 614400)
2. Save the script and change it to executable mode:
1 |
chmod 755 ~ /tools/batch/ramdisk .sh |
Running ramdisk.sh will create a memory disk:
1234567 |
$ 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 |
Now the Finder should be able to find a new device called Jdkramdisk, which contains the JDK. Click the "Eject" button to remove the RAM disk and release the appropriate memory.
If you want to use this technique, you need to have this memory disk every time you start Eclipse, or you will see "A Java Runtime ... must be available in order to run Eclipse" error. You can configure your system to use Automator or a UNCHTL daemon to ensure that ramdisk.sh scripts are executed automatically each time you start.
For Windows users:
1. Download and install the tool named ImDisk
2. Create a new batch file, such as: C:/tools/batch/ramdisk.bat
Replace the x, Y, and Z with your JDK version number:
12345678 |
@ 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 |
After running Ramdisk.bat, you will see that a new disk called "JDK RAMDISK" is created, containing the JDK.
3. Make sure the files are running in Administrator mode. Right-click the file and select "Properties--compatibility-check" Run this program as Administrator.
If you want to use this technique, you need to have this memory disk every time you start Eclipse, or you will see "A Java Runtime ... must be available in order to run Eclipse" error. You can configure the system to place the Ramdisk.bat script in the Startup folder.
In order for skill 3 to work, you need to add the-VM setting in the Eclipse.ini file (see the next section).
Tip 4: Adjust your Eclipse.ini
This is the most confusing part of Eclipse's optimization. There are a lot of articles on the Internet to introduce different configuration schemes. I'm just introducing my own configuration scheme.
Find your Eclipse.ini file:
- Windows/linux: Located inECLIPSe Hom e ( translation note : Eclipsehome (Translator Note: Eclipse_home is the path to ECLIPSE, assuming Linux is also installed on its own, not by source)
- MacOS: Located in $eclipse_home/eclipse.app/contents/macos
Understand the meaning of the next work ...
There are two types of properties in Eclipse.ini: Properties related to the Eclipse app, and JVM-related properties. These options depend on the version of JDK and Eclipse. Below is the latest list I found on the web.
To understand these properties, first understand the memory layout of the Oracle JVM. In general, JVM memory is divided into several memory pools, and objects are located in different memory pools depending on the time of their existence.
- The Eden Space (heap) is used for many objects that have just been created. Garbage collector each trip is typically handled here with the "New Generation" object, and all objects that are no longer used are removed.
- The Survivor Space (heap) contains objects that were not destroyed by GC two or three trips in Eden space. These objects still belong to the new generation, but move them to a more secure place, and the risk of being collected is greatly reduced. The garbage collector runs much less frequently here (the GC has judged that the objects here are often used, based on past experience).
- The tenured space (heap) contains objects that have survived for quite some time in the Survior space.
- Immortality (non-heap) contains the metadata of the JVM, such as class properties, methods, enumerations, and so on. Because this data can be shared among multiple JVMs. So the immortal generation reads and reads only two regions.
- The code cache (not the heap) provides the memory space for compiling and storing code.
If you're interested in this, Oracle has a great article on configuring garbage collection, which details the purpose of all of these spaces.
In Eclipse.ini, you can control the size of each memory pool. The following configuration is set for my 16G memory, but can also be used for 8G of memory.
Use the JDK located in RAM disk (using the version number in step three):
1 |
-vm /Volumes/JDKRAMDISK/jdk1 .x.y_z.jdk /Contents/Home/ |
Disable bytecode verification (risky)
This is to skip the validation of the class file (see here for the validation of the class file), meaning that the JVM does not detect the class file being used. If you use a class file that has been modified, there is a security risk. Take the risk yourself (I just use it when I play, and not enable it at work).
Turn on compiler performance optimizations
Increase the space of eternal life (the place where new objects are allocated) (translator Note: In JDK 8, the Life Generation was canceled)
12 |
-XX:PermSize=512m -XX:MaxPermSize=512m |
Increase the minimum maximum heap space (including Cenozoic and older generations)
Increase the size of the heap for the Cenozoic
Set the stack size for each thread
Adjust garbage collection
Finally, here are a list of other options that you might see online. As far as I am concerned, these options are not accelerated, so they are for reference only. Readers can find the appropriate documentation on the Web to understand and use the corresponding options:
12345678 |
-XX:MaxGCPauseMillis=10 -XX:+UseG1GC -XX:CompileThreshold=5 -XX:MaxGCPauseMillis=10 -XX:MaxHeapFreeRatio=70 -XX:+CMSIncrementalPacing -XX:+UseFastAccessorMethods -server |
Finally, remove all duplicate options, including launcher. Xxmaxpermsize, this option is useless because the xx:maxpermsize option is enabled.
Tip 5: Turn off antivirus software
If you have antivirus software, make sure that the software does not check the code folder. Add JDK, Eclipse, your. M2/jar code base, and code folders to the whitelist of your antivirus software.
Tip 6: Don't run svn and git in eclipse
This is a personal preference. Some people like to combine eclipse with team collaboration tools. As far as I'm concerned, this is slow, and I'd rather eclipse focus on development rather than doing a lot of things at once. I also like the svn/git command line very much. Anyway, I removed the tools from eclipse and found that the response was faster.
Tip 7: Use the keyboard
A bit of eclipse is that it contains a lot of shortcut keys. The reader can set the relevant shortcut keys on its own. In general I'll reset the debug keys so that it behaves the same as Visual Studio & Chrome Dev env. Take the time to learn the shortcut keys. The more shortcut keys you use, the faster you'll experience using Eclipse.
The shortcut keys are not introduced in depth, and readers can easily find relevant information on the Web. Some of the necessary shortcuts are listed below:
1234567891011 |
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 …… |
That's almost it. There is no comparison between Eclipse and other Ides, and I think Eclipse is a very powerful and fast Java code editing tool.
If you have other tricks, please let me know.
7 Tips for accelerating eclipse