我的程序一开始报java.lang.OutOfMemoryError: PermGen space异常,后来在网上查了一下资料,然后根据http://hi.baidu.com/tiger560/blog/item/498e72893ab69cb70e24444b.html上说的对tomcat进行了修改,修改后启动正常,但是在tomcat启动时修改程序源文件,保存后发现问题还没有彻底解决,控制台信息如下:
Setting DefaultObjectTypeDeterminer as default ...
- Filter initialized. Response buffering is enabled
- DWR Version 2.0.5 starting.
- - Servlet Engine: Apache Tomcat/6.0.16
- - Java Version: 1.5.0_14
- - Java Vendor: Sun Microsystems Inc.
- Clash of converters for com.berchina.vo.RuleAuthority. Using org.directwebremoting.convert.BeanConverter in place of org.directwebremoting.convert.BeanConverter
- Clash of converters for com.berchina.vo.CheckDateForUpdate. Using org.directwebremoting.convert.BeanConverter in place of org.directwebremoting.convert.BeanConverter
到这的时候就不在往下运行了,我打开一个页面想登陆这个系统,点击登陆后,控制台又输出异常信息:
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2" java.lang.OutOfMemoryError: PermGen space
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1" java.lang.OutOfMemoryError: PermGen space
Exception in thread "http-8080-2" java.lang.OutOfMemoryError: PermGen space
Exception in thread "com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Timer-1" java.lang.OutOfMemoryError: PermGen space
内存溢出。
如果你的应用中有很多CLASS的话,就很可能出现PermGen space错误,
这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下使用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)
那么就会产生此错误信息了。
解决方法: 手动设置MaxPermSize大小
修改TOMCAT_HOME/bin/catalina.sh
在“echo "Using CATALINA_BASE: $CATALINA_BASE"”上面加入以下行:
JAVA_OPTS="-server -XX:PermSize=64M -XX:MaxPermSize=128m
建议:将相同的第三方jar文件移置到tomcat/shared/lib目录下,这样可以达到减少jar 文档重复占用内存的目的。