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

18,436

Solution 1

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.

Solution 2

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.

Solution 3

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)

Share:
18,436
rl99
Author by

rl99

I am a Java developer. Interested in Web Technologies, SQL NoSQL, Scripting languages. New Technologies.

Updated on June 26, 2022

Comments

  • rl99
    rl99 almost 2 years

    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 the 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?