<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Ordinary hut

    人間一福地,勝似天仙宮
    posts - 61, comments - 50, trackbacks - 0, articles - 1

    ssh中需要增加IntrospectorCleanupListener監聽器

    Posted on 2009-11-26 16:29 landor 閱讀(3179) 評論(0)  編輯  收藏 所屬分類: spring
    增加方式如下:
        <listener>
            
    <listener-class>
                org.springframework.web.util.IntrospectorCleanupListener
            
    </listener-class>
        
    </listener>
    spring的說明如下:

    Listener that flushes the JDK's JavaBeans Introspector cache on web app shutdown. Register this listener in your web.xml to guarantee proper release of the web application class loader and its loaded classes.

    If the JavaBeans Introspector has been used to analyze application classes, the system-level Introspector cache will hold a hard reference to those classes. Consequently, those classes and the web application class loader will not be garbage-collected on web app shutdown! This listener performs proper cleanup, to allow for garbage collection to take effect.

    Unfortunately, the only way to clean up the Introspector is to flush the entire cache, as there is no way to specifically determine the application's classes referenced there. This will remove cached introspection results for all other applications in the server too.

    Note that this listener is not necessary when using Spring's beans infrastructure within the application, as Spring's own introspection results cache will immediately flush an analyzed class from the JavaBeans Introspector cache and only hold a cache within the application's own ClassLoader. Although Spring itself does not create JDK Introspector leaks, note that this listener should nevertheless be used in scenarios where the Spring framework classes themselves reside in a 'common' ClassLoader (such as the system ClassLoader). In such a scenario, this listener will properly clean up Spring's introspection cache.

    Application classes hardly ever need to use the JavaBeans Introspector directly, so are normally not the cause of Introspector resource leaks. Rather, many libraries and frameworks do not clean up the Introspector: e.g. Struts and Quartz.

    Note that a single such Introspector leak will cause the entire web app class loader to not get garbage collected! This has the consequence that you will see all the application's static class resources (like singletons) around after web app shutdown, which is not the fault of those classes!

    This listener should be registered as the first one in web.xml, before any application listeners such as Spring's ContextLoaderListener. This allows the listener to take full effect at the right time of the lifecycle.


    其中JavaBeans Introspector是一個類,位置在Java.bean.Introspector,這個類的用途是發現java類是否符合javaBean規范,也就是這個類是不是javabean。具體用法可以參照jdk文檔;

    上面的意思就是,如果有的框架或者程序用到了JavaBeans Introspector了,那么就啟用了一個系統級別的緩存,這個緩存會存放一些曾加載并分析過的javabean的引用,當web服務器關閉的時候,由于這個緩存中存放著這些javabean的引用,所以垃圾回收器不能對web容器中的javaBean對象進行回收,導致內存越來越大。

    spring提供的org.springframework.web.util.IntrospectorCleanupListener就解決了這個問題,他會在web服務器停止的時候,清理一下這個Introspector緩存。使那些javabean能被垃圾回收器正確回收。

    spring不會出現這種問題,因為spring在加載并分析完一個類之后會馬上刷新JavaBeans Introspector緩存,這樣就保證了spring不會出現這種內存泄漏的問題。

    但是有很多程序和框架在使用了JavaBeans Introspector之后,都沒有進行清理工作,比如quartz、struts;解決辦法很簡單,就是上面的那個配置。

    主站蜘蛛池模板: 国产啪亚洲国产精品无码| 免费观看理论片毛片| 亚洲精品乱码久久久久久蜜桃不卡| 亚洲综合欧美色五月俺也去| 免费精品国产自产拍在| 亚洲六月丁香六月婷婷蜜芽| 69天堂人成无码麻豆免费视频| 亚洲免费在线播放| 亚洲精品视频免费看| 亚洲国产精品综合久久20| 国产又黄又爽又猛免费app| 亚洲国产精品成人综合久久久| 国内精自视频品线六区免费| 亚洲精品网站在线观看你懂的| 国产黄色免费网站| 亚洲国产午夜精品理论片在线播放| 日韩免费视频播播| 人妻巨大乳hd免费看| 亚洲AV无码久久精品色欲| 久久国产高潮流白浆免费观看| 91亚洲自偷在线观看国产馆| 永久免费av无码网站大全| 免费大片黄在线观看| 国产成A人亚洲精V品无码性色| 91禁漫免费进入| 亚洲国产高清国产拍精品| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | eeuss免费天堂影院| 亚洲AV日韩精品久久久久久| 亚洲一区二区三区免费视频| 亚洲精品av无码喷奶水糖心| 亚洲综合色视频在线观看| 久久伊人免费视频| 亚洲精品无码中文久久字幕| 久久久久亚洲爆乳少妇无| 毛片无码免费无码播放| 亚洲色最新高清av网站| 亚洲中文字幕无码久久综合网| 精品国产污污免费网站aⅴ| 国产成人亚洲精品无码AV大片| 亚洲爆乳精品无码一区二区三区|