about one months ago, I published a blog that described love and hate for Eclipse Some people ask me how to give eclipse speed up, this article will discuss this issue. Incidentally, this article is not a comparison IDE, so don't say you hate an IDE and choose another one. 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.
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).
Tip 3: Place the JDK on the memory disk (RAM disk) (Bo main Note: This is a bit of a hassle and risk, if your memory is not very large, it is not recommended to try)
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:
#!/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:
chmod 755 ~/tools/batch/ramdisk.sh
Running ramdisk.sh will create a memory 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
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:
@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 in $eclipse_home (Translator Note: $ECLIPSE _home is the path to ECLIPSE, assuming Linux is also installed on its own, rather than through a source installation)
-
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):
-vm/volumes/jdkramdisk/jdk1.x.y_z.jdk/contents/home/
-VM N:/jdk1.x.y_z/bin
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
-xx:+aggressiveopts
Increase the space of eternal life (the place where new objects are allocated) (translator Note: In JDK 8, the Life Generation was canceled)
-xx:permsize=512m-xx:maxpermsize=512m
Increase the minimum maximum heap space (including Cenozoic and older generations)
-xms2048m-xmx2048m
Increase the size of the heap for the Cenozoic
-xmn512m
Set the stack size for each thread
-xss2m
Adjust garbage collection
-xx:+useparalleloldgc
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:
-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:
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.
Bo Main Note:
Configuration file Eclipse.ini in Eclipse or MyEclipse | Add the following to see more detailed garbage collection information in Myeclipse.ini:
-XX:+UseParallelOldGC
-XX:+PrintGCDetails
-Xloggc:D:/log/MyeclipseLog.gc
Original link: http://www.nicolasbize.com/blog/7-tips-to-speed-up-eclipse/
Link: http://www.importnew.com/13942.html
7 tricks to speed up eclipse (very good)