Eclipse的最佳JVM设置是什么?

时间:2020-03-06 14:48:46  来源:igfitidea点击:

我们发现运行Eclipse的最佳JVM设置是什么?

解决方案

这是我使用的(尽管我在快捷方式而不是设置文件中有它们):

eclipse.exe -showlocation -vm" C:\ Java \ jdk1.6.0_07 \ bin \ javaw.exe" -vmargs -Xms256M -Xmx768M -XX:+ UseParallelGC -XX:MaxPermSize = 128M

Eclipse喜欢大量的RAM。至少使用-Xmx512M。更多(如果有)。

-vm
C:\ Program Files \ Java \ jdk1.6.0_07 \ jre \ bin \ client \ jvm.dll

要指定我们使用的Java版本,并使用dll而不是启动javaw进程

-showlocation

为了使Eclipse运行两次更容易,并知道我们正在处理哪个工作区

Eclipse 3.6添加了一个首选项,以指定显示"工作区名称(显示在窗口标题中)"的内容,这比" -showlocation"要好得多,原因有以下三个:

  • 我们无需重新启动Eclipse即可生效。
  • 我们可以选择一个短代码。
  • 它首先出现在透视图和应用程序名称之前。

有关更多最新设置,请参见上面的Eclipse Galileo 3.5设置。

JDK

我认为,最好的JVM设置始终包括我们可以找到的最新JDK(因此,到目前为止,jdk1.6.0_b07直至b16,b14和b15除外)

eclipse.ini

即使内存设置很低,我也可以在带有2Go RAM的旧(2002)桌面上运行大型Java项目(以及Web服务器)。

-showlocation
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256M
-framework
plugins\org.eclipse.osgi_3.4.2.R34x_v20080826-1230.jar
-vm
jdk1.6.0_10\jre\bin\client\jvm.dll
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms128m
-Xmx384m
-Xss2m
-XX:PermSize=128m
-XX:MaxPermSize=128m
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:CompileThreshold=5
-Dcom.sun.management.jmxremote

有关新选项的更多详细信息,请参见GKelly的SO答案和Piotr Gabryanczyk的博客条目。

监控方式

我们还可以考虑启动:

C:\[jdk1.6.0_0x path]\bin\jconsole.exe

如先前关于内存消耗的问题所述。

如果使用的是Linux + Sun JDK / JRE 32位,请将" -vm"更改为:

-vm 
[your_jdk_folder]/jre/lib/i386/client/libjvm.so

如果我们使用的是Linux + Sun JDK / JRE 64位,请将" -vm"更改为:

-vm
[your_jdk_folder]/jre/lib/amd64/server/libjvm.so

在Ubuntu 8.10和9.04上对我来说效果很好

如果要使用jdk6 update 14,我建议使用似乎有助于提高性能的G1垃圾收集器。

为此,请删除以下设置:

-XX:+ UseConcMarkSweepGC
-XX:+ CMSIncrementalMode
-XX:+ CMSIncrementalPacing

并用以下内容替换它们:

-XX:+ UnlockExperimentalVMOptions
-XX:+ UseG1GC

当前(2009年11月),我正在使用jdk6 update 17测试以下配置选项集(使用Galileo -eclipse 3.5.x,对于Helios 3.6.x,请参见下面的3.4或者更高版本):
(当然,请使eclipse.ini中存在的相对路径适合设置的正确路径)

注意:对于eclipse3.5,将" startup"和" launcher.library"行替换为:

-startup
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519

eclipse.ini 3.5.1

-data
../../workspace
-showlocation
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
384m
-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-vm
../../../../program files/Java/jdk1.6.0_17/jre/bin/client/jvm.dll
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms128m
-Xmx384m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=384m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-Dcom.sun.management.jmxremote
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=C:/jv/eclipse/mydropins

另请参阅上面的原始答案以获取更多信息。

更改(从2009年7月开始)

  • 指的是启动器而不是框架
  • 共享插件:" org.eclipse.equinox.p2.reconciler.dropins.directory"选项。
  • Galileo支持工作空间或者VM的完全相对路径(避免将它们从一次eclipse安装更改为另一路径,当然,如果JVM和工作空间保持不变)以前,当eclipse启动时,这些相对路径始终被重写为绝对路径.....。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
  • 我们还可以在eclipse目录中复制Java JDK安装的JRE目录

注意事项

有一个错误的断点实际上与JDK有关。
一定要使用JDK6u16或者更新的版本来启动eclipse(然后可以在eclipse中定义要编译的JDK数量:不是因为必须使用同一JDK进行编译而使用JDK6启动eclipse)。

最大限度

请注意以下用途:

--launcher.XXMaxPermSize
384m
-vmargs
-XX:MaxPermSize=128m

如Eclipse Wiki中所述,

Eclipse 3.3 supports a new argument to the launcher: --launcher.XXMaxPermSize.

  If the VM being used is a Sun VM and there is not already a -XX:MaxPermSize= VM argument, then the launcher will automatically add -XX:MaxPermSize=256m to the list of VM arguments being used.

  The 3.3 launcher is only capable of identifying Sun VMs on Windows.

如本条目中所述:

Not all vms accept the -XX:MaxPermSize argument which is why it is passed in this manner. There may (or may not) exist problems with identifying sun vms.

  Note: Eclipse 3.3.1 has a bug where the launcher cannot detect a Sun VM, and therefore does not use the correct PermGen size. It seems this may have been a known bug on Mac OS X for 3.3.0 as well.

  If you are using either of these platform combination, add the -XX flag to the eclipse.ini as described above.
  
  Notes:
  
  
  the "384m" line translates to the "=384m" part of the VM argument, if the VM is case sensitive on the "m", then the so is this argument.  
  the "--launcher." prefix, this specifies that the argument is consumed by the launcher itself and was added to launcher specific arguments to avoid name collisions with application arguments. (Other examples are --launcher.library, --launcher.suppressErrors)
  
  
  The -vmargs -XX:MaxPermSize=384m part is the argument passed directly to the VM, bypassing the launcher entirely and no check on the VM vendor is used.

XX:+ UseParallelGC是有史以来最棒的选择!!!

我们也可以尝试使用JRockit运行。它是为服务器优化的JVM,但是许多长时间运行的客户端应用程序(例如IDE的应用程序)在JRockit上运行得很好。 Eclipse也不例外。 JRockit没有烫发空间,因此我们无需对其进行配置。

可以设置一个暂停时间目标(ms),以避免长时间的gc暂停会使UI停滞。

-showsplash
org.eclipse.platform
-vm
 C:\jrmc-3.1.2-1.6.0\bin\javaw.exe 
-vmargs
-XgcPrio:deterministic
-XpauseTarget:20

我通常不用理会-Xmx和-Xms的设置,而是让JRockit在必要时增大堆的大小。如果使用JRockit启动Eclipse应用程序,则还可以使用JRockit Mission Control工具套件监视,分析和查找应用程序中的内存泄漏。我们可以从此更新站点下载插件。注意,仅适用于Eclipse 3.3和Eclipse 3.4

又是一年中的那个时候:" eclipse.ini取3"设置反击!

替代文字http://www.eclipse.org/home/promotions/friends-helios/helios.png

在对Eclipse Ganymede 3.4.x和Eclipse Galileo 3.5.x进行设置之后,下面是对Eclipse Helios 3.6.x的"优化" eclipse.ini设置文件的深入了解:

  • 根据运行时选项,
  • 并使用7月27日发布的Sun-Oracle JVM 1.6u21 b7(可能涉及某些Sun专有选项)。

(通过"优化",我的意思是能够在工作中的workstation脚工作站上运行全功能的Eclipse,该设备是2002年的一些旧P4,带有2Go RAM和XPSp3. 但是我也在Windows7上测试了相同的设置)

Eclipse.ini

警告:对于非Windows平台,请使用Sun专有选项-XX:MaxPermSize而不是Eclipse专有选项--launcher.XXMaxPermSize
也就是说:除非我们使用的是最新的jdk6u21 build 7.
请参阅下面的Oracle部分。

-data
../../workspace
-showlocation
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vm
C:/Prog/Java/jdk1.6.0_21/jre/bin/server/jvm.dll
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Declipse.p2.unsignedPolicy=allow
-Xms128m
-Xmx384m
-Xss4m
-XX:PermSize=128m
-XX:MaxPermSize=384m
-XX:CompileThreshold=5
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+CMSIncrementalPacing
-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
-XX:+UseFastAccessorMethods
-Dcom.sun.management.jmxremote
-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=C:/Prog/Java/eclipse_addons

笔记:
将" p2.reconciler.dropins.directory"修改为我们选择的外部目录。
看到这个答案。
这样做的想法是能够独立于任何Eclipse安装将新插件拖放到目录中。

以下各节详细介绍了此eclipse.ini文件中的内容。

可怕的Oracle JVM 1.6u21(内部版本7)和Eclipse崩溃

Andrew Niefer确实提醒我注意这种情况,并写了一篇关于非标准vm参数(-XX:MaxPermSize)的博客文章,这可能导致其他供应商的vm根本无法启动。 但是该选项的eclipse版本(--launcher.XXMaxPermSize`)不能与新的JDK(6u21,除非我们使用的是6u21 build 7,请参见下文)一起使用。

最终的解决方案在Eclipse Wiki上,并且仅对于在6u21 pre build 7的Windows上的Helios:

  • 下载固定的eclipse_1308.dll(2010年7月16日)
  • 放进去
(eclipse_home)/plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.0.v20100503

而已。此处没有要调整的设置(再次,仅适用于6u21 pre build 7的Windows上的Helios)。
对于非Windows平台,我们需要恢复到Sun专有选项-XX:MaxPermSize

该问题基于一种回归:由于Oracle在java.exe中重新命名,导致JVM识别失败,并在Eclipse上触发了错误319514.
Andrew处理了Bug 320005 [launcher]--launcher.XXMaxPermSize:isSunVM对于Oracle应该返回true,但这仅适用于Helios 3.6.1.

Eclipse的另一位撰稿人Francis Upton对所有情况进行了反思。

7月27日更新u21b7:
Oracle已经退还对下一个Java 6版本的更改,并且直到JDK 7才会再次实现。
如果我们使用jdk6u21 build 7,则可以还原为--launcher.XXMaxPermSize(eclipse选项),而不是-XX:MaxPermSize(非标准选项)。
在C启动器shimeclipse.exe中发生的自动检测仍将寻找" Sun Microsystems"字符串,但是使用6u21b7,它将再次正常工作。

隐式-startup--launcher.library

现在,我仍然保留-XX:MaxPermSize版本(因为我不知道何时每个人都会用正确的JDK启动Eclipse)。

  • 启动:如果未指定,则可执行文件将在plugins目录中查找具有最高版本的org.eclipse.equinox.launcher捆绑包。
  • launcher.library:如果未指定,则可执行文件会在plugins目录中查找具有最高版本的适当的org.eclipse.equinox.launcher。[platform]片段,并在其中使用名为eclipse_ *的共享库。

使用JDK6

与先前的设置相反,这些模块的确切路径不再设置,这很方便,因为在不同的Eclipse 3.6.x版本之间它可能有所不同:

-Dosgi.requiredJavaVersion = 1.6

现在明确需要JDK6来启动Eclipse:

+ UnlockExperimentalVMOptions

这个SO问题报告了在Mac OS上进行开发的积极可能性。

-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
-XX:+UseFastAccessorMethods

以下选项是Sun JVM的一些实验选项的一部分。

在本博文中已报道了它们,可能会加快Eclipse的速度。
在此处以及官方Java Hotspot选项页面中查看所有JVM选项。
注意:这些选项的详细列表报告" UseFastAccessorMethods"在默认情况下可能处于活动状态。

As a reminder, G1 is the new garbage collector in preparation for the JDK 7, but already used in the version 6 release from u17.

从命令行在Eclipse中打开文件

另请参阅"更新JVM":

--launcher.defaultAction
openFile
This tells the launcher that if it is called with a command line that only contains arguments that don't start with "-", then those arguments should be treated as if they followed "--launcher.openFile".
eclipse myFile.txt
This is the kind of command line the launcher will receive on windows when you double click a file that is associated with eclipse, or you select files and choose "Open With" or "Send To" Eclipse.
  
  Relative paths will be resolved first against the current working directory, and second against the eclipse program directory.

请参阅Andrew Niefer的博客文章,报告此新选项:

p2和"未签名"对话框提示

请参阅错误301033以供参考。最初是错误4922(2001年10月,在9年后修复)。

如果我们在安装许多插件的过程中对这个对话框感到厌倦,请执行以下操作:

-Declipse.p2.unsignedPolicy=allow

,在eclipse.ini中添加:

I do want to say that security research supports the fact that less prompts are better.

  People ignore things that pop up in the flow of something they want to get done.
  
  For 3.6, we should not pop up warnings in the middle of the flow - no matter how much we simplify, people will just ignore them.

  Instead, we should collect all the problems, do not install those bundles with problems, and instead bring the user back to a point in the workflow where they can fixup - add trust, configure security policy more loosely, etc. This is called 'safe staging'.

请参阅Chris Aniszczy的这篇博客文章,以及错误报告235526.

其他选项

--------- http://www.eclipse.org/home/categories/images/wiki.gif替代文本http://www.eclipse.org/home/categories/images/wiki.gif替代文字http://www.eclipse.org/home/categories/images/wiki.gif

Windows7上的user.home问题

这些选项不是直接在上面的eclipse.ini中,但是如果需要的话可以派上用场。

当eclipse启动时,它将读取其密钥库文件(保存密码),该文件位于user.home中。
如果由于某种原因user.home无法正确地将其自身解析为完整路径,那么Eclipse将不会启动。
最初在此SO问题中提出,如果我们遇到这种情况,则需要将密钥库文件重新定义为显式路径(开始时不再需要user.home进行解析)

-eclipse.keyring 
C:\eclipse\keyring.txt

添加eclipse.ini

调试模式

错误300577对此进行了跟踪,已在其他SO问题中解决了该问题。

-debug

等一下,Eclipse中有多个设置文件。
如果我们在eclipse.ini中添加以下选项:

org.eclipse.equinox.p2.core/debug=true
org.eclipse.equinox.p2.core/reconciler=true
P2 will inform you what bundles were found in dropins/ folder, what request was generated, and what is the plan of installation. Maybe it is not detailed explanation of what actually happened, and what went wrong, but it should give you strong information about where to start:
  
  
  was your bundle in the plan? 
  Was it installation problem (P2 fault) 
  or maybe it is just not optimal to include your feature?

,启用调试模式,Eclipse将寻找另一个设置文件:.options文件,我们可以在其中指定一些OSGI选项。
当我们通过dropins文件夹添加新插件时,这很棒。
如本博客文章" Dropins诊断"中所述,在.options文件中添加以下设置:

Unzip eclipse-SDK-3.5M5-win32.zip to ..../eclipse
Unzip mdt-ocl-SDK-1.3.0M5.zip to ..../eclipse/dropins/mdt-ocl-SDK-1.3.0M5
This is a problematic configuration since OCL depends on EMF which is missing.

  3.5M5 provides no diagnosis of this problem.
  
  Start eclipse.

  No obvious problems. Nothing in Error Log.
  
  
  Help / About / Plugin details shows org.eclipse.ocl.doc, but not org.eclipse.ocl.
  Help / About / Configuration details has no (diagnostic) mention of
  org.eclipse.ocl.
  Help / Installation / Information Installed Software has no mention of org.eclipse.ocl.
  
  
  Where are the nice error markers?

清单类路径

来自Bug 264924 [reconciler]没有诊断dropins问题,最终解决了以下问题:

In Galileo (aka Eclipse 3.5), JDT started resolving manifest classpath in libraries added to project’s build path. This worked whether the library was added to project’s build path directly or via a classpath container, such as the user library facility provided by JDT or one implemented by a third party. 
  In Helios, this behavior was changed to exclude classpath containers from manifest classpath resolution.

请参阅此博客文章:

-DresolveReferencedLibrariesForContainers=true

这意味着某些项目可能不再在Helios中编译。
如果要还原为伽利略的行为,请添加:

IPV4堆栈

有关参考,请参见错误305037,错误313965和错误313890。

-Djava.net.preferIPv4Stack=true

这样的SO问题在不访问插件更新站点时提到了一个潜在的修复方法:

JVM1.7x64潜在的优化

此处提及的目的是为了防止它对配置有所帮助。

For the record, the very fastest options I have found so far for my bench test with the 1.7 x64 JVM n Windows are:
-Xincgc 
-XX:-DontCompileHugeMethods 
-XX:MaxInlineSize=1024  
-XX:FreqInlineSize=1024
But I am still working on it...

本文报道:

-vm
C:/Program Files (x86)/Java/jdk1.7.0/bin
-startup
plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20100628
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-server
-Dosgi.requiredJavaVersion=1.7
-Xmn100m
-Xss1m
-XgcPrio:deterministic
-XpauseTarget:20
-XX:PermSize=400M
-XX:MaxPermSize=500M
-XX:CompileThreshold=10
-XX:MaxGCPauseMillis=10
-XX:MaxHeapFreeRatio=70
-XX:+UnlockExperimentalVMOptions
-XX:+DoEscapeAnalysis
-XX:+UseG1GC
-XX:+UseFastAccessorMethods
-XX:+AggressiveOpts
-Xms512m
-Xmx512m

我自己的设置(Java 1.7,修改为1.6):

-XX:MaxPermSize

如果我们喜欢我,并且在当前的Oracle 1.6版中遇到问题,那么我们可能要更新JDK或者设置

段落数量不匹配