IntrospectorCleanupListener作用
来源:互联网 发布:优秀搜索引擎 知乎 编辑:程序博客网 时间:2024/05/20 00:10
原文链接:http://blog.sina.com.cn/s/blog_534f69a001013a20.html
"在服务器运行过程中,Spring不停的运行的计划任务和OpenSessionInViewFilter,使得Tomcat反复加载对象而产生框架并用时可能产生的内存泄漏,则使用IntrospectorCleanupListe
对于这一句话,引用关于IntrospectorCleanupListe
用法很简单,就是在web.xml中加入:
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListe
</listener>
只知道servlet标准不允许在web容器内自行做线程管理,quartz的问题确实存在。
对于Web容器来说,最忌讳应用程序私自启动线程,自行进行线程调度,像Quartz这种在web容器内部默认就自己启动了10线程进行异步job调度的框架本身就是很危险的事情,很容易造成servlet线程资源回收不掉,所以我一向排斥使用quartz。
quartz还有一个问题就是不支持cluster。导致使用quartz的应用都没有办法做群集。
原文链接:http://www.cnblogs.com/qiankun-site/p/5886673.html
IntrospectorCleanupListener作用
<!--web.xml-->
<listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class></listener>
1、此监听器主要用于解决java.beans.Introspector导致的内存泄漏的问题
2、此监听器应该配置在web.xml中与Spring相关监听器中的第一个位置(也要在ContextLoaderListener的前面)
3、JDK中的java.beans.Introspector类的用途是发现Java类是否符合JavaBean规范如果有的框架或程序用到了Introspector类,那么就会启用一个系统级别的缓存,此缓存会
存放一些曾加载并分析过的JavaBean的引用。当Web服务器关闭时,由于此缓存中存放着这些JavaBean的引用,所以垃圾回收器无法回收Web容器中的JavaBean对象,最后导致
内存变大。而org.springframework.web.util.IntrospectorCleanupListener就是专门用来处理Introspector内存泄漏问题的辅助类。IntrospectorCleanupListener会在
Web服务器停止时清理Introspector缓存,使那些Javabean能被垃圾回收器正确回收。Spring自身不会出现这种问题,因为Spring在加载并分析完一个类之后会马上刷新
JavaBeans Introspector缓存,这就保证Spring中不会出现这种内存泄漏的问题。但有些程序和框架在使用了JavaBeans Introspector之后,没有进行清理工作(如 Quartz,Struts),最后导致内存泄漏
IntrospectorCleanupListener源码:
public class IntrospectorCleanupListener implements ServletContextListener { public IntrospectorCleanupListener() { } public void contextInitialized(ServletContextEvent event) { CachedIntrospectionResults.acceptClassLoader(Thread.currentThread().getContextClassLoader()); } public void contextDestroyed(ServletContextEvent event) { CachedIntrospectionResults.clearClassLoader(Thread.currentThread().getContextClassLoader()); Introspector.flushCaches(); }}
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- IntrospectorCleanupListener作用
- 既然琴瑟起 IntrospectorCleanupListener作用
- IntrospectorCleanupListener
- IntrospectorCleanupListener
- IntrospectorCleanupListener
- IntrospectorCleanupListener
- org.springframework.web.util.IntrospectorCleanupListener作用
- org.springframework.web.util.IntrospectorCleanupListener的作用
- Spring框架中IntrospectorCleanupListener的作用
- org.springframework.web.util.IntrospectorCleanupListener监听器的作用
- org.springframework.web.util.IntrospectorCleanupListener监听器的作用
- python学习语法
- 米谟科技 3D音频VR编辑器——sound flare声弹是什么
- 散列 开放定址法 C实现
- 前端知识点总结(JavaScript篇)
- 如何解决每次向后台发起请求时判断用户是否处于登录状态?
- IntrospectorCleanupListener作用
- WPF 加载H5页面
- react-bits:Proxy Component
- JavaScript 常见安全漏洞和自动化检测技术
- 使用idea一次性清理所有java文件中多余导入未使用的包
- 每天一个Linux命令(35):ln命令
- loop与for loop分别实现乘法口诀表
- java swing 学习 教程之三
- VC热键控件(Hot Key Controls)