Eclipse:An internal error occurred during: "Build Project". GC overhead limit exceeded

简介: 版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/45225413 ...
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/45225413

在使用Eclipse的Build Project功能时,提示以下错误:
An internal error occurred during: “Build Project”. GC overhead limit exceeded
如图:
这里写图片描述
搜索的一下,是属于java.lang.OutOfMemoryError。
OOM大家都知道,就是JVM内存溢出了,那GC overhead limit exceed呢?

GC overhead limt exceed检查是Hotspot VM 1.6定义的一个策略,通过统计GC时间来预测是否要OOM了,提前抛出异常,防止OOM发生。Sun 官方对此的定义是:“并行/并发回收器在GC回收时间过长时会抛出OutOfMemroyError。过长的定义是,超过98%的时间用来做GC并且回收了不到2%的堆内存。用来避免内存过小造成应用不能正常工作。“

听起来没啥用…预测OOM有啥用?起初开来这玩意只能用来Catch住释放内存资源,避免应用挂掉。后来发现一般情况下这个策略不能拯救你的应用,但是可以在应用挂掉之前做最后的挣扎,比如数据保存或者保存现场(Heap Dump)。

而且有些时候这个策略还会带来问题,比如加载某个大的内存数据时频繁OOM。

**用于了一两年了,今天突然遇到这个问题,也许是以前没留意。
其实如果不是很频繁的出现,也不需要留意它,直接点OK就好了。**
之后会弹出提示如下:
这里写图片描述

如果担心还有没保存的修改,就点No,检查完毕后重启一下Eclipse。

解决方法:
原因是Eclipse默认配置内存太小需要更改Eclipse安装文件夹下的eclipse.ini文件。

Eclipse.ini默认文件如下:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Xms1024m
-Xmx1536m
-XX:MaxPermSize=1024m

修改如下:

-Xms512m -Xmx1024m

第一个是最小的初始化内存,第二个是最大的占有内存

还可以加上 -XX:MaxPermSize=1024m这个意思是在编译文件时一直占有最大内存,重启Eclipse

2017-12-20更新

补一个 macOS 下的 Eclipse.ini 文件内容:

-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
--launcher.library
/Users/aven/.p2/pool/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.401.v20161122-1740
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.appendVmargs
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/bin
-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/

macOS 下的 Eclipse.ini 文件在哪?

目录
相关文章
|
5月前
|
Java Android开发
Eclipse里面导工程的时候报错faceted project problem
Eclipse里面导工程的时候报错faceted project problem
|
C语言 Android开发 Windows
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: <stdio.h>”错误的方法
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: <stdio.h>”错误的方法
解决windows下eclipse创建project时没有include导致出现“unresolved inclusion: <stdio.h>”错误的方法
|
8月前
|
Java Android开发 Windows
成功解决eclipse启动报错 Error:Could not create the Java Virtual Machine Error:A fatal exception has occurred
成功解决eclipse启动报错 Error:Could not create the Java Virtual Machine Error:A fatal exception has occurred
|
11月前
|
Java Maven Android开发
eclipse 安装maven 同时、解决自带的maven无法读取本地架包的问题、解决:找不到符号 [ERROR] 符号: 变量
1、安装在参考别人的帖子的,直接看就行了 2、解决 找不到符号 [ERROR] 符号: 变量,解决得有点辛酸
58 0
eclipse 安装maven 同时、解决自带的maven无法读取本地架包的问题、解决:找不到符号 [ERROR]   符号:   变量
|
11月前
|
Java Android开发 Windows
Eclipse启动时发生An internal error occurred during: “Initializing Java Tooling“.错误的解决方法
Eclipse启动时发生An internal error occurred during: “Initializing Java Tooling“.错误的解决方法
|
Java Android开发
eclipse中提示change project compliance and jre to 1.7
eclipse中提示change project compliance and jre to 1.7
83 0
eclipse中提示change project compliance and jre to 1.7
|
Java Android开发
Eclipse打不开,出现an error has occured see the log file(日志中出现!MESSAGE FrameworkEvent ERROR !STACK 0)问题
Eclipse打不开,出现an error has occured see the log file(日志中出现!MESSAGE FrameworkEvent ERROR !STACK 0)问题
565 0
Eclipse打不开,出现an error has occured see the log file(日志中出现!MESSAGE FrameworkEvent ERROR !STACK 0)问题
|
Java Android开发
Eclipse中出现Java compiler level does not match the version of the installed java project facet问题
Eclipse中出现Java compiler level does not match the version of the installed java project facet问题
98 0
Eclipse中出现Java compiler level does not match the version of the installed java project facet问题
|
Java Android开发
eclipse project修改 output folder
eclipse project修改 output folder
|
XML 编解码 前端开发
myeclipse及Eclipse中.classpath、.project、.settings、.mymetadata(myeclipse特有)介绍(下)
myeclipse及Eclipse中.classpath、.project、.settings、.mymetadata(myeclipse特有)介绍(下)
133 0
myeclipse及Eclipse中.classpath、.project、.settings、.mymetadata(myeclipse特有)介绍(下)