天天看點

JVM crash due to perm gen space 99% in use

問題描述:

TransformerFactory tFactory = TransformerFactory. newInstance (); 

Transformer transformer = tFactory.newTransformer(new StreamSource(inputStream));

transformer.transform(xmlSource, outputTarget);//crash here

JAVA代碼中調用Transformer轉換xslt檔案到xml檔案時出現crash,crash 檔案摘要:

Heap 

 def new generation   total 314560K, used 5786K [0x04600000, 0x19b50000, 0x19b50000) 

  eden space 279616K,   2% used [0x04600000, 0x04ba6b80, 0x15710000) 

  from space 34944K,   0% used [0x15710000, 0x15710000, 0x17930000) 

  to   space 34944K,   0% used [0x17930000, 0x17930000, 0x19b50000) 

 tenured generation   total 699072K, used 48833K [0x19b50000, 0x44600000, 0x44600000) 

   the space 699072K,   6% used [0x19b50000, 0x1cb005f0, 0x1cb00600, 0x44600000) 

 compacting perm gen  total 86272K, used 86136K [0x44600000, 0x49a40000, 0x64600000) 

   the space 86272K,  99% used [0x44600000, 0x49a1e2f8, 0x49a1e400, 0x49a40000) 

No shared spaces configured. 

日志顯示perm gen空間不夠,轉換xslt确實需要load大量DLL檔案,網絡上最多的解決方案就是增加JVM參數MaxPermSize值:

-XX:MaxPermSize=512M 

按照這個方法逐漸加大幾次值後還是一直crash,而且發現一個有趣的現象:

compacting perm gen  total 86272K, 

這個值一直沒有變化,為什麼?heap足夠大的情況下,JVM還沒有來得及增加perm gen就挂了?于是增加JVM參數直接初始化:

-XX:PermSize=512M 

結果問題解決,看來這可能是JVM的bug,有空測測JRE7。

vm_info: Java HotSpot(TM) Client VM (20.4-b02) for windows-x86 JRE (1.6.0_29-b11), 

built on Oct  3 2011 01:01:08 by "java_re" with MS VC++ 7.1 (VS2003) 

本文轉自sarchitect 51CTO部落格,原文連結:http://blog.51cto.com/stevex/1113493,如需轉載請自行聯系原作者