java jeeout_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虚拟机的参数来解决的。可是究竟应该修改成多少,却有许多不同的说法。e76df30f42298a6bec75f206b4befa63.png

为此,仔细查看了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-vmargscommand line argument, which must follow all other Eclipse specific arguments. Thus, to increase the available heap memory, you would typically use:eclipse -vmargs -Xmx

with thevalue 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= argument:eclipse -vmargs -XX:MaxPermSize=

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参数清空。

再次尝试,成功!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值