Use Introspectorcleanuplistener to resolve memory leak issues when using frameworks such as spring, structs, etc.

Source: Internet
Author: User

In Java development, if the framework or program uses JavaBeans Introspector, then a system-level cache is enabled, which holds references to JavaBean that have been loaded and analyzed, and when the Web server shuts down, Because these javabean references are stored in this cache, the garbage collector cannot reclaim the JavaBean objects in the Web container, causing the memory to become larger. A listener named Org.springframework.web.util.IntrospectorCleanupListener is provided in spring. It is primarily responsible for handling buffer leaks caused by the use of JavaBeans introspector.

(official explanation) Introspectorcleanuplistener is a listener that clears the JavaBeans introspector when the Web app is closed. Web. XML to register this listener. When the app shuts down, it frees the class loader associated with the Web app and the classes it manages. Note that the spring The managed bean does not need to use this listener. Because the buffers used by spring's own introspection are parsed out of a class and are immediately removed from the JavaBeans Introspector in the buffer. Classes in your application never use JavaBeans introspector directly. So they generally do not cause internal viewing of resource leaks. But some class libraries and frameworks often produce this problem. For example: Struts and quartz. A single internal view leak can cause the entire web app's classloader to not be garbage collected. After the web app is closed, you'll see all of the static class resources for this app (for example, Singleton). This error is certainly not caused by the class itself.

How to use: Configure in the Web. xml file

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

Use Introspectorcleanuplistener to resolve memory leak issues when using frameworks such as spring, structs, etc.

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.