Tomcat memory leak Problem Analysis, tomcatleak

Source: Internet
Author: User

Tomcat memory leak Problem Analysis, tomcatleak

Analysis of Tomcat memory leak problems

The following web applications were stopped (reloaded, undeployed), but their classes from previous runs are still loaded in memory, thus causing a memory leak (use a profiler to confirm): 

When you use Maven to redeploy a project on Tomcat, the memory leaks because the previous classes has not been uninstalled and still exists in the jvm memory,

However, some people say that they should stop the project before uninstalling the project, and then undeploy will not see the memory leak.

Stack Overflow:

If you want to make sure not to cause leaks you have to do the following:

Make sure your web application does not use any java classes that are in the web container shared libraries. if you have any shared libraries, make sure there is no strong references to the objects in those libraries Avoid using static variables, especially on java objects like HashTable, Sets, etc. if you need to, make sure that you call remove to release the objects with the maps, lists...

Here is also a good article on ThreadLocal and MemoryLeaks-https://blog.arendsen.net/index.php/2005/02/22/threadlocals-and-memory-leaks-revisited/

1. Avoid using the libraries in the container. If you need to use them, avoid using strong references to those libraries.

2. Avoid using static variables, especially containers such as map and set as static variables.

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.