开发者

A web application appears to have started a thread named [22] but has failed to stop it. This is very likely to create a memory leak

I have a web application with Servlets in the back end deployed over tomcat. The application is simple java application.

I see this error frequently in t开发者_运维问答he server logs: SEVERE: A web application appears to have started a thread named [22] but has failed to stop it. This is very likely to create a memory leak.

Are there any potential reasons which might be causing it?


I'd use visualvm 1.3.2 and see what threads are being created. Be sure to add all the plug-ins.

If it's not being done by your code you won't have much control over it.

You also don't know if the message is a red herring or not. Load test your code over a period of time and measure what happens.


I faced similar situation recently Resolved in below steps

  1. I took Thread dump. ( using Kill -QUIT pid )
  2. Found the Runnable/Thread class form dump
  3. Then i put a debug point in run method and started application in debug mode.
  4. Got the code which starts My Thread and I observed it was not stopped while stoping application.
  5. Introduced code to stop the thread in contextDestroyed method of AppContextListener (This is My application class which extends ServletContextListener ) as this method will be called when i stop tomcat.

If you set Thread as Dameon Thread it is not going to help , you can visit explanation.


Tomcat waits for all the application's threads (user threads not daemon threads) to stop before it goes down, I guess that in your case this specific thread is a user thread and therefore tomcat generated this error. I suggest you to change this thread to daemon (assuming this one is yours)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜