tomcat5.5 reload 出现方法区溢出的问题
来源:互联网 发布:天翼飞young3.09 算法 编辑:程序博客网 时间:2024/06/05 19:35
最近在用eclipse调试一个老项目,server用的tomcat5.5, reload了几次应用就报错,方法区溢出:
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space。
用visualvm查看heap dump,发现项目中的第三方jar包的类都被重新加载了好几次,最后方法区空间不足,一直进行fullgc,却无法回收重复的类。
用tomcat7相同环境下运行正常,reload几次后,方法区空间不足时,会回收所有原先WebappClassLoader重复加载的类,。
2个tomcat jvm运行模式和参数都一致,都是使用默认的垃圾回收机制,后来tomcat5.5试着用了CMS垃圾收集器还是报原先的错误:
应该是tomcat5.5 reload代码实现有问题tomcat7的reload源码,应该tomcat7在reload时清理引用做了写改进吧,WebappClassLoader处理内存泄露 clearReferences():
用tomcat7相同环境下运行正常,reload几次后,方法区空间不足时,会回收所有原先WebappClassLoader重复加载的类,。
2个tomcat jvm运行模式和参数都一致,都是使用默认的垃圾回收机制,后来tomcat5.5试着用了CMS垃圾收集器还是报原先的错误:
-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
应该是tomcat5.5 reload代码实现有问题tomcat7的reload源码,应该tomcat7在reload时清理引用做了写改进吧,WebappClassLoader处理内存泄露 clearReferences():
/** * Clear references. */ protected void clearReferences() { // De-register any remaining JDBC drivers clearReferencesJdbc(); // Stop any threads the web application started clearReferencesThreads(); // Check for leaks triggered by ThreadLocals loaded by this class loader checkThreadLocalsForLeaks(); // Clear RMI Targets loaded by this class loader clearReferencesRmiTargets(); // Null out any static or final fields from loaded classes, // as a workaround for apparent garbage collection bugs if (clearReferencesStatic) { clearReferencesStaticFinal(); } // Clear the IntrospectionUtils cache. IntrospectionUtils.clear(); // Clear the classloader reference in common-logging if (clearReferencesLogFactoryRelease) { org.apache.juli.logging.LogFactory.release(this); } // Clear the resource bundle cache // This shouldn't be necessary, the cache uses weak references but // it has caused leaks. Oddly, using the leak detection code in // standard host allows the class loader to be GC'd. This has been seen // on Sun but not IBM JREs. Maybe a bug in Sun's GC impl? clearReferencesResourceBundles(); // Clear the classloader reference in the VM's bean introspector java.beans.Introspector.flushCaches(); }查了相关的资料:
一般程序库可能存在内存泄漏的地方有:
1.JDBC驱动注册
2.一些日志框架
3.在ThreadLocal中保存对象,但是并不去删除它
4.启动了线程,但没有停止它
而Java API存在内存泄漏的地方包括:
1.使用javax.imageio API (the Google Web Toolkit can trigger this)
2.使用java.beans.Introspector.flushCaches() (Tomcat does this to prevent memory leaks caused by this caching)
3.使用XML解析器(the root cause is unknown due to a bug in the JRE)
4.使用RMI远程方法调用(somewhat ironically, causes a leak related to the garbage collector)
5.从Jar文件中读取资源
0 0
- tomcat5.5 reload 出现方法区溢出的问题
- wabacus框架在Myeclipse reload过程中方法区溢出问题讨论
- SetFilePointer出现溢出的问题
- Dom的reload方法
- IFrame的Reload方法
- Python 的reload()方法
- 解决Tomcat出现内存溢出的问题
- 解决ANT出现的内存溢出问题
- SESSION持久化的方法 TOMCAT5.5
- Tomcat5.5中数据源配置的问题
- 解决Tomcat5.5的虚拟目录配置问题
- tomcat5.5的问题及其解决办法
- 在Eclipse关闭tomcat5.5的时候就会出现Failed shutdown of Apache Portable Runtime的问题的解决方法
- 关于pjax.reload()加载页面时出现aborted超时终止的问题
- jmeter 压测时nginx,使用nginx -s reload出现tcp reset 问题的思考
- tomcat5.0和tomcat5.5配置问题,二者是有区别的
- tomcat5.0和tomcat5.5配置问题,二者是有区别的
- size_t的使用中出现的vector溢出问题
- 内核隐含规则问题
- 随机实现100以内的的加减乘除运算
- System.Web.HttpException: 请求已超时
- NYOJ 673 悟空的难题
- php汉字转成拼音函数
- tomcat5.5 reload 出现方法区溢出的问题
- 做可双击运行的Jar包(右键选择用java(TM)打开)
- 【安卓笔记】activity生命周期
- GCD编程学习笔记
- MMU
- Google App Engine的app.yaml详细说明
- 进程与线程的一个简单解释(目前看到的关于进程和线程说明最好的博文)
- 删除SVN版本控制
- UVA 11354 Bond