On 24/03/2022 07:57, Thomas Hoffmann (Speed4Trade GmbH) wrote:

<snip/>

Is it correct, that every spawned thread must call tl.remove() to cleanup all 
the references to prevent the logged warning (and not only the main thread)?

Yes. Or the threads need to exit.

Second question is: How might it cause a memory leak?
The threads are terminated and hold a reference to this static variable. But on 
the other side, that class A is also eligible for garbage collection after 
undeployment.
So both, the thread class and the class A are ready to get garbage collected. 
Maybe I missed something (?)

It sounds as if the clean-up is happening too late. Tomcat expects clean-up to be completed once contextDestroyed() has returned for all ServLetContextListeners. If the clean-up is happening asynchronously (e.g. the call is made to stop the threads but doesn't wait until the threads have stopped) you could see this message.

In this case it sounds as if you aren't going to get a memory leak but Tomcat can't tell that at the point it checks.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to