Want to make your Eclipse run faster? Try this

  sonic0002        2014-06-10 05:31:11       3,423        0    

Lots of us may find that our Eclipse takes a long time to launch, remember how many times you want to close this heavy machine and shout "F**K". Do you know why Eclipse launches slowly? Is it because we have too many plugins installed or we have created too many projects? No, it's not. Sometimes, it's because we don't have the correct configuration. So where to start? Go to eclipse.ini.

First, you may want to add below line in your eclipse.ini configuration file:

-Xloggc:gc.log

This is to show what Eclipse has done while launching.

Next we can start to do some optimization. Here we take one example, the memory on the machine to be optimized is 3.16G.

The first optimization

Set -Xms and -Xmx to 512m to avoid frequent GC. Below are the configurations:

-Xms512m
-Xmx512m
-verbose:gc
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-Xloggc:gc.log

Now restarting Eclipse, we will see that there are 8 times of Full GC and 3 times of monitor GC, the logs are:

2014-06-09T20:39:00.480+0800: 1.850: [GC 1.850: [DefNew: 139776K->17472K(157248K), 0.0613123 secs] 139776K->20106K(506816K), 0.0614226 secs] [Times: user=0.06 sys=0.00, real=0.06 secs]
2014-06-09T20:39:01.214+0800: 2.597: [Full GC 2.597: [Tenured: 2634K->35922K(349568K), 0.1242231 secs] 81163K->35922K(506816K), [Perm : 16383K->16383K(16384K)], 0.1243415 secs] [Times: user=0.11 sys=0.01, real=0.13 secs]
2014-06-09T20:39:01.698+0800: 3.075: [Full GC 3.075: [Tenured: 35922K->38486K(349568K), 0.1086032 secs] 121915K->38486K(506816K), [Perm : 20479K->20479K(20480K)], 0.1087152 secs] [Times: user=0.11 sys=0.00, real=0.11 secs]
2014-06-09T20:39:02.026+0800: 3.408: [Full GC 3.408: [Tenured: 38486K->39671K(349568K), 0.1166902 secs] 52893K->39671K(506816K), [Perm : 24575K->24575K(24576K)], 0.1168707 secs] [Times: user=0.13 sys=0.00, real=0.13 secs]
2014-06-09T20:39:02.558+0800: 3.926: [Full GC 3.926: [Tenured: 39671K->41312K(349568K), 0.1572323 secs] 57131K->41312K(506816K), [Perm : 28671K->28650K(28672K)], 0.1573102 secs] [Times: user=0.16 sys=0.00, real=0.16 secs]
2014-06-09T20:39:03.276+0800: 4.653: [Full GC 4.653: [Tenured: 41312K->44308K(349568K), 0.1656481 secs] 87405K->44308K(506816K), [Perm : 32767K->32767K(32768K)], 0.1657328 secs] [Times: user=0.17 sys=0.00, real=0.17 secs]
2014-06-09T20:39:04.058+0800: 5.439: [GC 5.439: [DefNew: 139776K->17472K(157248K), 0.0356182 secs] 184084K->62657K(506816K), 0.0357149 secs] [Times: user=0.05 sys=0.00, real=0.05 secs]
2014-06-09T20:39:04.105+0800: 5.475: [GC 5.475: [DefNew: 19934K->7K(157248K), 0.0245383 secs] 65119K->62662K(506816K), 0.0246034 secs] [Times: user=0.02 sys=0.00, real=0.02 secs]
2014-06-09T20:39:04.136+0800: 5.507: [Full GC 5.507: [Tenured: 62654K->62672K(349568K), 0.1803366 secs] 68235K->62672K(506816K), [Perm : 36863K->36863K(36864K)], 0.1804263 secs] [Times: user=0.17 sys=0.00, real=0.17 secs]
2014-06-09T20:39:04.839+0800: 6.215: [Full GC 6.215: [Tenured: 62672K->64003K(349568K), 0.2267431 secs] 198067K->64003K(506816K), [Perm : 40959K->40959K(40960K)], 0.2268157 secs] [Times: user=0.23 sys=0.00, real=0.23 secs]
2014-06-09T20:39:06.417+0800: 7.796: [Full GC 7.796: [Tenured: 64003K->71144K(349568K), 0.3148881 secs] 182608K->7

From the logs, we can see the cause of Full GC is Perm, we can do some more optimization.

The second optimization

We can set the initial and maximum PermSize to 512m.

-Xms512m
-Xmx512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-verbose:gc
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-Xloggc:gc.log

Now we will see the logs like:

2014-06-09T20:43:29.442+0800: 1.872: [GC 1.872: [DefNew: 139776K->17472K(157248K), 0.0614285 secs] 139776K->20106K(506816K), 0.0615441 secs] [Times: user=0.06 sys=0.00, real=0.06 secs]
2014-06-09T20:43:30.426+0800: 2.852: [GC 2.852: [DefNew: 157248K->17472K(157248K), 0.0714705 secs] 159882K->37813K(506816K), 0.0715851 secs] [Times: user=0.06 sys=0.02, real=0.08 secs]
2014-06-09T20:43:32.176+0800: 4.608: [GC 4.608: [DefNew: 157248K->17472K(157248K), 0.0846898 secs] 177589K->59609K(506816K), 0.0848035 secs] [Times: user=0.09 sys=0.00, real=0.09 secs]
2014-06-09T20:43:32.676+0800: 5.099: [GC 5.099: [DefNew: 157248K->3513K(157248K), 0.0443054 secs] 199385K->63063K(506816K), 0.0444509 secs] [Times: user=0.05 sys=0.00, real=0.05 secs]
2014-06-09T20:43:33.285+0800: 5.705: [GC 5.705: [DefNew: 143289K->10365K(157248K), 0.0427973 secs] 202839K->69914K(506816K), 0.0428756 secs]

There is no Full GC anymore, but we see 5 Minor GC, this is because we don't have the -Xmn set.

The third optimization

Set -Xmn to 256m. Below are the logs:

2014-06-09T20:45:29.204+0800: 2.500: [GC 2.500: [DefNew: 209792K->26176K(235968K), 0.0951747 secs] 209792K->35901K(498112K), 0.0952914 secs] [Times: user=0.09 sys=0.00, real=0.09 secs]
2014-06-09T20:45:31.220+0800: 4.515: [GC 4.515: [DefNew: 235968K->22389K(235968K), 0.1084576 secs] 245693K->58147K(498112K), 0.1085766 secs] [Times: user=0.11 sys=0.00, real=0.11 secs]
2014-06-09T20:45:32.001+0800: 5.302: [GC 5.302: [DefNew: 232181K->5280K(235968K), 0.0570383 secs] 267939K->63248K(498112K), 0.0571581 secs]

Only 3 minor GC left.

The final configuration may look like:

-Xmn256m
-Xms512m
-Xmx512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-verbose:gc
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-Xloggc:gc.log

Hope this can help you. If you have better methods, please feel free to share with us.

Reference : http://www.itjhwd.com/qtbzff-eclipse/

OPTIMIZATION  ECLIPSE  SPEED 

       

  RELATED


  0 COMMENT


No comment for this article.



  RANDOM FUN

HR gets an HR