org.springframework.web.util.IntrospectorCleanu...

看到好多项目的web.xml中都配置了java

Xml代码 复制代码  收藏代码
  1. <listener>  
  2.       <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>  
  3. </listener>  
<listener>
      <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>

 这个是什么东东呢?web

这是Introspector 缓存清除监听器 spring

        Spring 提供了一个名为 org.springframework.web.util.IntrospectorCleanupListener 的监听器。它主要负责处理由 JavaBean Introspector 功能而引发的缓存泄露。IntrospectorCleanupListener 监听器在 Web 应用关闭的时会负责清除 JavaBean Introspector 的缓存,在 web.xml 中注册这个监听器能够保证在 Web 应用关闭的时候释放与其相关的 ClassLoader 的缓存和类引用。若是您使用了 JavaBean Introspector 分析应用中的类,Introspector 缓存会保留这些类的引用,结果在应用关闭的时候,这些类以及Web 应用相关的 ClassLoader 不能被垃圾回收。不幸的是,清除 Introspector 的惟一方式是刷新整个缓存,这是由于无法准确判断哪些是属于本 Web 应用的引用对象,哪些是属于其它 Web 应用的引用对象。因此删除被缓存的 Introspection 会致使将整个 JVM 全部应用的 Introspection 都删掉。须要注意的是,Spring 托管的 Bean 不须要使用这个监听器,由于 Spring 的 Introspection 所使用的缓存在分析完一个类以后会立刻从 javaBean Introspector 缓存中清除掉,并将缓存保存在应用程序特定的 ClassLoader 中,因此它们通常不会致使内存资源泄露。可是一些类库和框架每每会产生这个问题。例如 Struts 和 Quartz 的 Introspector 的内存泄漏会致使整个的 Web 应用的 ClassLoader 不能进行垃圾回收。在 Web 应用关闭以后,您还会看到此应用的全部静态类引用,这个错误固然不是由这个类自身引发的。解决这个问题的方法很简单,您仅需在 web.xml 中配置 IntrospectorCleanupListener 监听器就能够了缓存

相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息