Ubuntu – Eclipse using high CPU after upgrade to Ubuntu 16.04

16.04cpu loadeclipse

I recently upgraded one of my systems to 16.04 and one of the many things that stopped working properly is the Eclipse IDE. It is now using about 60% of the CPU, even when the window is minimised, is very slow and some things are even unresponsive.

Following this answer at Stack Exchange I investigated a bit which thread is causing this behaviour:

$ ps -mo 'pid lwp stime time pcpu' -C java
  PID   LWP STIME     TIME %CPU
14475     - 09:55 00:02:05 91.6
    - 14475 09:55 00:00:00  0.0
    - 14476 09:55 00:01:14 54.6

Translating to hexadecimal:

$ printf "0x%x\n" 14476
0x388c

In the logs I found the following regarding this thread:

"main" #1 prio=6 os_prio=0 tid=0x00007f10c000a000 nid=0x388c runnable [0x00007f10c8c62000]
   java.lang.Thread.State: RUNNABLE
    at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
    at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9326)
    at org.eclipse.swt.widgets.Display.eventProc(Display.java:1225)
    at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
    at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2435)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3428)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1488)

I also tried increasing available memory, but it fixed nothing. The contents of my eclipse.ini file:

-startup
plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.300.v20150602-1417
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.7
-XX:MaxPermSize=256m
-Xms512m
-Xmx1024m

I have a relatively small number of plug-ins installed: TeXlipse, StatET and Papyrus. This same set up with the same JVM (1.8.0_11) runs flawlessly on Ubuntu 14.04

Best Answer

This is a bug related to GTK3. To correct it, it is necessary to force eclipse to use GTK2. I noticed a decrease in CPU consumption, yet consumption remains significant.

Add these 2 lines before the line --launcher.appendVmargs in eclipse.ini:

--launcher.GTK_version
2

More information at:

Related Question