您的位置:首页 > 编程语言 > Java开发

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded

2016-04-19 15:30 288 查看
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded问题的解决办法.

一、异常如下:

Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded

二、产生原因:

意味着太多的时间花在了垃圾收集上面,SUN的建议是指定垃圾回收的算法,加上启动参数-XX:-UseGCOverheadLimit,从而限制JVM在抛出OutOfMemoryError之前限制其耗费在GC上的时间。

SUN的原文:

The parallel / concurrent collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be
thrown. This feature is designed to prevent applications from running for an extended period of time while *** little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the
command line.

jvm gc行动中跨越98%以上的时间去释放小于2%的堆空间时会报这个错误。

JDK6新增错误类型。当GC为释放很小空间占用大量时间时抛出。

一般是因为堆太小。导致异常的原因:没有足够的内存。

三、解决方案:

1、查看系统是否有使用大内存的代码或死循环。

2、可以添加JVM的启动参数来限制使用内存:-XX:-UseGCOverheadLimit

3、在bin/catalina.sh增大Xms和Xmx:

JAVA_OPTS=””-Xms512m -Xmx4096m -XX:MaxPermSize=128m -XX:-UseGCOverheadLimit -XX:+UseConcMarkSweepGC””

-Xms512m 初始的java内存堆大小 256M

-Xmx4096m 最大的java内存堆大小 2048M

-XX:PermSize=128m GC预留的内存,假如你的应用有大量的Class被动态载进或卸载,你应该不这个参数设大些

-XX:MaxPermSize=256m 最大的GC预留内存

-Dsun.rmi.dgc.client.gcInterval=3600000 RMI客户端GC发生周期的设定

-Dsun.rmi.dgc.server.gcInterval=3600000 RMI服务端GC发生周期的设定

四、java命令

1、jps 类似UNIX的ps命令

2、jstat 用于输出给定java进程的统计信息。

3、jmap JAVA Memory Map

4、jconsole Java Monitoring and Management Console
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: