Use introspectorcleanuplistener to solve the problem of Memory leakage caused by quartz

Source: Internet
Author: User

"During server running, spring keeps running scheduled tasks and opensessioninviewfilter, which causes tomcat to repeatedly load objects to generate a framework and possibly cause memory leakage, use introspectorcleanuplistener as the corresponding solution. "

For this sentence, refer to the explanation of the introspectorcleanuplistener section:

 spring provides a listener named org. springframework. Web. util. introspectorcleanuplistener. It is mainly responsible for Handling Buffer leaks caused by the use of JavaBeans introspector. Spring describes it as follows: it is a listener that clears JavaBeans introspector when the web application is disabled. web. register this listener in XML. when the web application is closed, you can release the Class Loader related to the web application and the class managed by the web application. If you use JavaBeans introspector to analyze the classes in the application, the introspector buffer retains references to these classes. as a result, when your application is closed, these classes and class loaders related to web applications are not garbage collected. unfortunately, the only way to clear introspector is to refresh the entire buffer. this is because we cannot determine which references belong to your application. therefore, deleting the buffered introspection will delete the introspection of all applications on this computer. note that spring-managed beans do not need to use this listener. because the buffer used by spring's introspection is immediately removed from the ans introspector buffer after a class is analyzed. the classes in the application  Program  never directly use JavaBeans introspector. therefore, they generally do not cause leakage of internal viewing resources. however, some class libraries and frameworks often cause this problem. for example, Struts and quartz. the leakage of a single internal view will prevent the class loaders of the entire web application from performing garbage collection. after the web application is disabled, you will see all static class resources of the application (for example, Singleton ). of course this error is not caused by this class. the usage is very simple, that is, in the web. add 
   
   
     Org. springframework. web. util. introspectorcleanuplistener 
    
   

Only that servlet standards do not allow thread management in Web containers. The problem with quartz exists.

For Web containers, the most taboo is that applications start threads without permission and perform Thread Scheduling on their own, by default, frameworks such as quartz which start 10 threads for asynchronous Job Scheduling in the Web container itself are very dangerous, and Servlet thread resources may not be recycled, therefore, I have always refused to use quartz.

Another problem with quartz is that it does not support cluster. As a result, no quartz application can be used as a cluster.

If it is mine, the method I take is to independently start a job server to run the job and will not be deployed in the Web container.

Original article link: http://yangzb.iteye.com/blog/1009103

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.