近期遇到一個JVM崩潰問題,JVM在運行不定時間後會崩潰,崩潰的時間沒發現有什麼規律,有多是一兩天,有多是一個月,近半年大概發生了3次,在第三次發生的時候終於引發了樓主的關注,樓主決定想辦法處理掉它,下面分享一下處理的過程。java
首先貼上hs.log(日誌太長,只貼出一部分),以下:nginx
# # An unexpected error has been detected by Java Runtime Environment: # # java.lang.OutOfMemoryError: requested 1310720 bytes for GrET in C:\BUILD_AREA\jdk6_07\hotspot\src\share\vm\utilities\growableArray.cpp. Out of swap space? # # Internal Error (allocation.inline.hpp:42), pid=3640, tid=5204 # Error: GrET in C:\BUILD_AREA\jdk6_07\hotspot\src\share\vm\utilities\growableArray.cpp # # Java VM: Java HotSpot(TM) Server VM (10.0-b23 mixed mode windows-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 (0x65b7e400): VMThread [stack: 0x66bf0000,0x66c40000] [id=5204] Stack: [0x66bf0000,0x66c40000] [error occurred during error reporting (printing stack bounds), id 0xc0000005] VM_Operation (0x713bf5d4): ParallelGCFailedAllocation, mode: safepoint, requested by thread 0x6a8e1000
相信不少人會和樓主同樣,第一眼就定位到Out of swap space,交換空間溢出?什麼鬼?徹底沒遇到過,因而百度了一下,發現也有很多遇到此類問題的,大概看了一些回覆,都是諸如:增長內存配置,增長操做系統交換空間之類的。仔細閱讀了下崩潰日誌,發現內存回收正常。跟內存溢出徹底不要緊呀。web
java.lang.OutOfMemoryError: requested 1310720 bytes for GrET in C:\BUILD_AREA\jdk6_07\hotspot\src\share\vm\utilities\growableArray.cpp. Out of swap space?windows
從新解讀一下上述英文描述:爲GrET申請內存時交換空間溢出,並且標出路徑在C:\BUILD_AREA\jdk6_07\hotspot\src\share\vm\utilities\growableArray.cpp裏,初步能夠判定問題是發生在growableArray.cpp這裏,首先百度下growableArray.cpp是什麼,此次好像查到點上了,在Oracle的bug庫裏找到了這個問題,詳情請戳:JDK-6806226 : Signed integer overflow in growable array code causes JVM crashapp
Bug Description中提到,在growableArray.cpp存在一個有符號數溢出的Bug,在堆比較大的狀況下會致使JVM崩潰。webapp
緣由終於找到了,原來是幾年前JVM的一個Bug,已經在jdk1.6.0_14裏修復。樓主從幾個相關的報告中找到了幾種解決方法,以下:jsp
1.bug已經在jdk 6 update 14中修復,只要升級到jdk1.6.0_14以後的版本便可ide
6806226 is fixed in jdk 6 update 14.
2.使用 -XX:+UseParallelOldGC垃圾收集器替代,不想升級jdk的能夠試試這個應急方法spa
The UseParallelOldGC does not need to move aside the mark words so does not need to do the allocation that fails. Use -XX:+UseParallelOldGC as a workaround.
3.hotspot虛擬機版本使用24.0以後的版本操作系統
The code in hsx24 has been fixed.
樓主選擇了升級jdk方法,目前JVM運行穩定,還沒有出現此問題,持續觀察中。。。