首页 > 编程语言 > 详细

spring监听器--------IntrospectorCleanupListener

时间:2015-09-23 10:41:02      阅读:193      评论:0      收藏:0      [点我收藏+]

web.xml中的配置:

<listener>
       <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
 </listener>

作用:保证在web 应用关闭的时候释放与掉这个web 应用相关的class loader 和由它管理的类。

注意:

1.    spring 托管的bean不需要使用这个监听器,因为spring它自己的introspection所使用的缓冲在分析完一个类之后会被马上从javaBeans Introspector缓冲中清除掉,应用程序中的类从来不直接使用JavaBeans Introspector,所以他们一般不会导致内存资源泄露。

2.    与一些类库和框架(例如:Struts 和Quartz)整合使用时,造成内存泄漏会导致整个的web应用的类加载器不能进行垃圾回收-----此应用的所有静态类资源(例如单例)在web应用关闭之后未被释放,而导致内存泄露的根本原因其实并不是这些未被回收的类

3.    IntrospectorCleanupListener应该注册为web.xml中的第一个Listener,在任何其他Listener之前注册,比如在Spring‘s ContextLoaderListener注册之前,才能确保IntrospectorCleanupListener在Web应用的生命周期适当时机生效。

spring监听器--------IntrospectorCleanupListener

原文:http://my.oschina.net/u/1989867/blog/509886

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!