升级到 Ubuntu 16.04 后 Eclipse 使用高 CPU

升级到 Ubuntu 16.04 后 Eclipse 使用高 CPU

我最近将我的一个系统升级到 16.04,Eclipse IDE 停止正常工作。它现在占用了大约 60% 的 CPU,即使窗口最小化,运行速度也很慢,有些东西甚至没有响应。

下列的Stack Exchange 上的这个答案我调查了一下哪个线程导致了这种行为:

$ 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

转换为十六进制:

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

在日志中我发现了与该线程相关的以下内容:

"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)

我也尝试增加可用内存,但什么也没解决。我的文件内容eclipse.ini

-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

我安装了相对较少的插件:TeXlipse、StatET 和 Papyrus。同样的设置和同样的 JVM(1.8.0_11)在 Ubuntu 14.04 上完美运行

答案1

这是与 GTK3 相关的错误。要纠正它,必须强制 eclipse 使用 GTK2。我注意到 CPU 消耗有所减少,但消耗仍然很大。

--launcher.appendVmargs在 eclipse.ini 中的行前添加以下两行:

--launcher.GTK_version
2

更多信息请访问:

相关内容