我们在生产环境中以不可预测的方式面临以下问题 有时服务器在一天或有时在一周内关闭,下面是确切的错误 dump,下面是服务器的设置。
JDK: jdk1.6.0_21 Server: Tomcat 7.0.2 OS: Red Hat Enterprise Linux Server release 5.5
在catalina.sh中,已完成以下设置:
JAVA_OPTS="-Xms1024M -Xmx1536M -XX:+HeapDumpOnOutOfMemoryError -XX:+AggressiveOpts
-XX:-DisableExplicitGC -XX:AdaptiveSizeThroughPutPolicy=0
-XX:+UsePSAdaptiveSurvivorSizePolicy
-XX:+UseAdaptiveGenerationSizePolicyAtMinorCollection
-XX:+UseAdaptiveGenerationSizePolicyAtMajorCollection -XX:PermSize=768M
-XX:MaxPermSize=768M -XX:+PrintGCDetails -Xloggc:/tmp/gcLogs.txt"
export CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=22222
-Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.password.file=/jakarta-tomcat7/apache-tomcat-7.0.2/conf
/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/jakarta-tomcat7/apache-
tomcat-7.0.2/conf/jmxremote.access"
# # A fatal error has been detected by the Java Runtime Environment: # # java.lang.OutOfMemoryError: requested 1958536 bytes for Chunk::new. Out of swap space? # # Internal Error (allocation.cpp:215), pid=18658, tid=589781904 # Error: Chunk::new # # JRE version: 6.0_21-b06 # Java VM: Java HotSpot(TM) Server VM (17.0-b16 mixed mode linux-x86 ) # If you would like to submit a bug report, please visit: # http://java.sun.com/webapps/bugreport/crash.jsp # --------------- T H R E A D --------------- Current thread (0x23787400): JavaThread "CompilerThread0" daemon [_thread_in_native, id=18668, stack(0x231f5000,0x23276000)] Stack: [0x231f5000,0x23276000], sp=0x23272e70, free space=1f723276000k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x6a9262] V [libjvm.so+0x2b277f] V [libjvm.so+0x12e03c] V [libjvm.so+0x12e536] V [libjvm.so+0x5d67d0] V [libjvm.so+0x2f809d] V [libjvm.so+0x4f65a9] V [libjvm.so+0x27b85f] V [libjvm.so+0x278043] V [libjvm.so+0x209767] V [libjvm.so+0x280f8c] V [libjvm.so+0x280839] V [libjvm.so+0x66feb6] V [libjvm.so+0x66959e] V [libjvm.so+0x57a89e] C [libpthread.so.0+0x5832] Current CompileTask: C2:3230 ! org.apache.jsp.com.common.press_jsp._jspService(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V (4433 bytes) --------------- P R O C E S S --------------- Java Threads: ( => current thread ) 0x09a21400 JavaThread "http-8080-exec-904" daemon [_thread_in_native, id=17126, stack(SIGTERM: [libjvm.so+0x57aaf0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 SIGQUIT: [libjvm.so+0x57aaf0], sa_mask[0]=0x7ffbfeff, sa_flags=0x10000004 --------------- S Y S T E M --------------- OS:Red Hat Enterprise Linux Server release 5.5 (Tikanga) uname:Linux 2.6.18-194.17.1.el5PAE #1 SMP Mon Sep 20 07:34:07 EDT 2010 i686 libc:glibc 2.5 NPTL 2.5 rlimit: STACK 10240k, CORE 0k, NPROC 114688, NOFILE 1024, AS infinity load average:0.39 0.54 0.38 CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 11, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3 Memory: 4k page, physical 6228576k(225096k free), swap 6974456k(6974352k free) vm_info: Java HotSpot(TM) Server VM (17.0-b16) for linux-x86 JRE (1.6.0_21-b06), built on Jun 22 2010 01:04:46 by "java_re" with gcc 3.2.1-7a (J2SE release) time: Fri Dec 10 14:01:06 2010 elapsed time: 79552 seconds
提前致谢, 阿米特
答案 0 :(得分:6)
对于记录(和Google),这看起来像both these个错误,这些错误已在sun的jdk的1.6u22版本中得到修复。所以,首先要做的是更新你的JVM。如果它仍然发生,并且总是在特定方法上发生,那么您可以使用以下jvm标志从编译中排除该方法(只要您了解其中的性能影响):
-XX:CompileCommand=exclude,org/apache/velocity/runtime/directive/Foreach,render
(如建议here)。但是,首先更新你的jvm。
答案 1 :(得分:4)
你正在运行许多影响内存的JVM args。您是否尝试过凭经验删除每个选项以查看哪个选项导致OOM?这个特定的OOM不是来自Java堆,而是来自JVM自己的C堆。
答案 2 :(得分:3)
正如其他答案/评论所述,您的内存不足。鉴于您的JVM设置,我会说根本原因是99%可能是内存泄漏。
如果你在Tomcat实例中进行了大量的热加载,那可能只是由此引起的。热负载因泄漏内存而臭名昭着,在实践中你无能为力......除了更频繁地退出和重启你的Tomcat。
另一种可能性是您的应用程序正在泄漏内存。如果是这种情况,那么您将需要使用内存分析器来追踪泄漏。
OOME导致JVM崩溃的事实很有意思,但可能并不重要。 (看起来JVM试图在内存耗尽时JIT编译从JSP生成的类。请求的块相当大,但这可能意味着你有一个相当大/复杂的JSP。)