Eclipse java.lang.OutOfMemoryError: Java heap space故障处理过程

最近在eclipse-jee-luna-SR2-win32开发环境(java version:1.7.0_60)下导入JEECG3.5.2开源项目过程中发现在build workspace过程中报Internal Error,查看workspace文件夹下的.metadata文件夹中的.log文件发现有下面的错误:

!ENTRY org.eclipse.core.jobs 4 2 2015-08-04 18:37:10.621
!MESSAGE An internal error occurred during: "Building workspace".
!STACK 0
java.lang.OutOfMemoryError: Java heap space
 at org.eclipse.wst.jsdt.internal.core.index.DiskIndex.readStreamChars(DiskIndex.java:884)
 at org.eclipse.wst.jsdt.internal.core.index.DiskIndex.readCategoryTable(DiskIndex.java:632)
 at org.eclipse.wst.jsdt.internal.core.index.DiskIndex.addQueryResults(DiskIndex.java:199)
 at org.eclipse.wst.jsdt.internal.core.index.Index.query(Index.java:154)
 at org.eclipse.wst.jsdt.internal.core.search.matching.FieldPattern.queryIn(FieldPattern.java:330)
 at org.eclipse.wst.jsdt.internal.core.search.matching.InternalSearchPattern.findIndexMatches(InternalSearchPattern.java:92)
 at org.eclipse.wst.jsdt.internal.core.search.matching.OrPattern.findIndexMatches(OrPattern.java:59)
 at org.eclipse.wst.jsdt.internal.core.search.matching.MatchLocator.findIndexMatches(MatchLocator.java:407)
 at org.eclipse.wst.jsdt.internal.core.search.PatternSearchJob.search(PatternSearchJob.java:116)
 at org.eclipse.wst.jsdt.internal.core.search.PatternSearchJob.execute(PatternSearchJob.java:66)
 at org.eclipse.wst.jsdt.internal.core.search.processing.JobManager.performConcurrentJob(JobManager.java:280)

......

在网上有不少关于这个错误的解决方案,试了几个都没有效果。大致思路都是通过修改Eclipse的内存分配的方法,通过修改Eclipse首选项中Java虚拟机的参数来解决的。可是究竟应该修改成多少,却有许多不同的说法。

为此,仔细查看了eclipse-jee-luna-SR2-win32的readme_eclipse.html文档(位于安装路径下的readme文件夹中)。在文档的第4部分“Running Eclipse”中的“Allocating enough memory and solving OutOfMemoryErrors”部分给出了这个问题的答案:

By default, Eclipse will allocate up to 512 megabytes of Java heap memory. This should be ample for all typical development tasks. However, depending on the JRE that you are running, the number of additional plug-ins you are using, and the number of files you will be working with, you could conceivably have to increase this amount.  Eclipse allows you to pass arguments directly to the Java VM using the -vmargs command line argument, which must follow all other Eclipse specific arguments. Thus, to increase the available heap memory, you would typically use:

eclipse -vmargs -Xmx<memory size>

with the <memory size> value set to greater than "512M" (512 megabytes -- the default).

When using an Oracle VM below 1.8, you may also need to increase the size of the permanent generation memory.  The default maximum is 64 megabytes, but more may be needed depending on your plug-in configuration and use.  When the VM runs out of permanent generation memory, it may crash or hang during class loading. This failure is less common when using Oracle JRE version 1.5.0_07 or greater. The maximum permanent generation size is increased using the -XX:MaxPermSize=<memory size> argument:

eclipse -vmargs -XX:MaxPermSize=<memory size>

This argument may not be available for all VM versions and platforms; consult your VM documentation for more details.

Note that setting memory sizes to be larger than the amount of available physical memory on your machine will cause Java to "thrash" as it copies objects back and forth to virtual memory, which will severely degrade your performance.

受此启发,这次没再进入Eclipse环境去通过设置首选项来设置JVM的内存,而是创建了一个eclipse的快捷方式,在快捷方式中将缺省的D:\eclipse-jee-luna-SR2-win32\eclipse.exe修改为D:\eclipse-jee-luna-SR2-win32\eclipse.exe -vmargs -Xmx1024M并将开发环境中之前尝试过程中设置的JVM参数清空。

再次尝试,成功!

时间: 2024-08-28 21:13:14

Eclipse java.lang.OutOfMemoryError: Java heap space故障处理过程的相关文章

Eclipse运行程序提示:Exception in thread &quot;main&quot; java.lang.OutOfMemoryError: Java heap space

问题描述: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 问题原因: 程序中对象引用过多导致堆空间不足,导致内存溢出 解决方案: (增大Java虚拟机的内存空间) 打开Eclipse,选择"Run" - "Run Configurations" - "(x)=Arguments",VM arguments栏中填写 -Xmx800m

Eclipse迅速执行:Exception in thread &amp;quot;main&amp;quot; java.lang.OutOfMemoryError: Java heap space

问题叙述性说明: Exception in thread "main" java.lang.OutOfMemoryError: Java heap space 问题原因: 程序中对象引用过多导致堆空间不足,导致内存溢出 解决方式: (增大Java虚拟机的内存空间) 打开Eclipse.选择"Run" - "Run Configurations" - "(x)=Arguments",VM arguments栏中填写 -Xmx80

eclipse中报错:java.lang.OutOfMemoryError: Java heap space

问题: 在eclipse中运行java程序,去重100多万的数据,报如下错误: java.lang.OutOfMemoryError: Java heap space 异常原因: 在JVM中如果98%的时间是用于GC且可用的 Heap size 不足2%的时候将抛出此异常信息. JVM堆的设置是指java程序运行过程中JVM可以调配使用的内存空间的设置.JVM在启动的时候会自动设置Heap size的值,其初始空间(即-Xms)是物理内存的1/64,最大空间(-Xmx)是物理内存的1/4.可以利

eclipse使用hadoop插件出现java.lang.OutOfMemoryError: Java heap space

14/09/20 22:41:13 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 14/09/20 22:41:13 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applicati

eclipse运行程序时报java.lang.OutOfMemoryError: Java heap space内存不足问题

System.setProperty("webdriver.firefox.bin", "D:\\Mozilla Firefox\\firefox.exe"); ProfilesIni pi = new ProfilesIni(); FirefoxProfile profile = pi.getProfile("default"); WebDriver driver = new FirefoxDriver(profile); driver.get

解决eclipse maven install 造成JVM 内存溢出(java.lang.OutOfMemoryError: Java heap space)

maven install 报错信息: The system is out of resources.Consult the following stack trace for details.java.lang.OutOfMemoryError: Java heap space at java.util.HashMap.createEntry(HashMap.java:897) at java.util.HashMap.addEntry(HashMap.java:884) at java.ut

java.lang.OutOfMemoryError: Java heap space解决办法

//首先检查程序有没有限入死循环 这个问题主要还是由这个问题 java.lang.OutOfMemoryError: Java heap space 引起的.第一次出现这样的的问题以后,引发了其他的问题.在网上一查可能是JAVA的堆栈设置太小的原因. 跟据网上的答案大致有这两种解决方法: 1.设置环境变量 解决方法:手动设置Heap size 修改TOMCAT_HOME/bin/catalina.sh set JAVA_OPTS= -Xms32m -Xmx512m 可以根据自己机器的内存进行更改

java.lang.OutOfMemoryError:Java heap space

1.错误描述 (mx.messaging.messages:ErrorMessage)#0 body = (null) clientId = "82C12FAA-ED2A-16A4-4FEA-720F521A5727" extendedData = (null) faultCode = "Server.Processing" faultDetail = (null) faultString = "java.lang.OutOfMemoryError:Jav

java.lang.OutOfMemoryError: Java heap space解决方法

//首先检查程序有没有限入死循环 这个问题主要还是由这个问题 java.lang.OutOfMemoryError: Java heap space 引起的.第一次出现这样的的问题以后,引发了其他的问题.在网上一查可能是JAVA的堆栈设置太小的原因. 跟据网上的答案大致有这两种解决方法: 1.设置环境变量 解决方法:手动设置Heap size 修改TOMCAT_HOME/bin/catalina.sh set JAVA_OPTS= -Xms32m -Xmx512m 可以根据自己机器的内存进行更改