问题描述:
- 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
,如需转载请自行联系原作者