在使用eclipse时,报错An internal error occurred during: "Building workspace". GC overhead limit exceeded
,该错误就是JVM内存溢出了,sun官方对GC overhead limit exceeded
的定义大概就是说,JVM花费了98%的时间进行垃圾回收,而只得到2%可用的内存,频繁的进行内存回收(最起码已经进行了5次连续的垃圾回收),JVM就会曝出java.lang.OutOfMemoryError: GC overhead limit exceeded错误。
一、报错如图所示:
之后会出现如下弹框:
如果还有没保存的修改,就点No,检查完毕后重启一下Eclipse;点Yes就退出了eclipse。
二、解决思路
报出该错误的原因是eclipse的默认配置内存太小,我们要更改eclipse的安装文件夹下eclipse.ini文件来将eclipse的配置内存调大。
三、解决
#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.6
-Xms512m
-Xmx1024m
-XX:MaxPermSize=1024m
修改配置如下:
-Xms512m #最小的初始化内存
-Xmx1024m #最大的占有内存
-XX:MaxPermSize=1024m #在编译文件时一直占有最大内存(这项配置可以不加)
保存修改的配置文件后,重启eclipse即可。