JVM报错GC overhead limit exceeded

这是生产上报的错,通过修改jetty.sh 里面的配置,目前没有发生异常,具体如图

 具体参考的文章如下:

May 31, 2012 11:54:25 AM org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler process
SEVERE: Error reading request, ignored
java.lang.OutOfMemoryError: GC overhead limit exceeded
Exception in thread "http-80-43" java.lang.NullPointerException
        at java.util.concurrent.ConcurrentLinkedQueue.offer(ConcurrentLinkedQueue.java:273)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler$1.offer(Http11Protocol.java:537)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler$1.offer(Http11Protocol.java:554)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:618)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
        at java.lang.Thread.run(Thread.java:619)
May 31, 2012 11:55:46 AM org.apache.coyote.http11.Http11Processor process
SEVERE: Error processing request
java.lang.OutOfMemoryError: GC overhead limit exceeded
May 31, 2012 11:56:58 AM org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor processChildren

问题产生原因:

根据sun的说法: "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."

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

处理方法:

1. 在jvm启动参数中添加 "-XX:-UseGCOverheadLimit",该参数在JDK6中默认启用("-XX:+UseGCOverheadLimit")。

  调整后的生产环境中使用的参数为: 

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

2. 检查是否有使用了大量内存的代码或死循环

3. 使用jstat命令监控gc行为是否正常

  jstat监控gc的命令格式为:

  jstat -gcutil [-t] [-h<lines>] <vmid> [<interval> [<count>]] 

  vmid为JVM进程id,可以用ps -ef 或 jps -lv命令查找。

  以下命令为每1秒钟输出一次gc状态,共输入5次

[root@localhost bin]# jstat -gcutil 7675 1000 5
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
.00   0.00  41.98   9.53  99.26    230    0.466   186   24.691   25.156
.00   0.00  41.98   9.53  99.26    230    0.466   186   24.691   25.156
.00   0.00  41.98   9.53  99.26    230    0.466   186   24.691   25.156
.00   0.00  41.98   9.53  99.26    230    0.466   186   24.691   25.156
.00   0.00  41.98   9.53  99.26    230    0.466   186   24.691   25.156

经过一段时间的观察,没有再出现该异常。

参考:

jstat - Java Virtual Machine Statistics Monitoring Tool

猜你喜欢

转载自blog.csdn.net/HXNLYW/article/details/82627258