Tomcat memory leak問題分析,tomcatleak

來源:互聯網
上載者:User

Tomcat memory leak問題分析,tomcatleak

Tomcat memory leak問題分析

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): 

使用Maven 在Tomcat 上 重新部署項目時記憶體流失,原因之前的classes沒有卸載還存在 jvm 記憶體中,

不過在有人說在卸載項目之前先 stop一下項目,再 undeploy 就不會出現 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是避免使用容器中的庫,如果非要使用,避免使用強引用指向那些庫

2是避免使用靜態變數,特別是把map,set等容器作為靜態變數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.