Possible memory leak with tomcat

I developed Webbapp that makes extensive use of threads. We need to control some resources at fixed intervals, and then act.

For this, we have developed ThreadManagerone that wraps one ScheduledThreadPoolExecutor . We allow any of the executor methods, we use this manager only so that everyone uses the same instance of the thread pool (manager - Singleton ...)

Then, when we close the context, we have ServletContextListenerone that takes care of the proper closing of the executor:

 ejecutor.shutdown();
 try
 {
      ejecutor.awaitTermination(10, TimeUnit.SECONDS);
 }
 catch (InterruptedException ie)
 {
     Thread.currentThread().interrupt();
 }
 System.out.println("Llamo al shutdownnow");
 ejecutor.shutdownNow();
 ejecutor = null;

But then when we close tomcat / unload the context, we get many errors saying:

GRAVE: The web application [/qsys] appears to have started a thread named [pool-4-thread-1] but has failed to stop it. This is very likely to create a memory leak.

, , , , tomcat.

?

: , , , Executor. interrupt() , :

System.out.println("Me intentan interrumpir!!");
run = false;
super.interrupt();

contextDestroyed , ... !

ExecuteExistingDelayedTasksAfterShutdownPolicy false...

...

+3
1

, - :

, ScheduledThreadPoolExecutor, tomcat undeploy/close/restart, ( , tomcat , , , , ...), ...

, ScheduledThreadPoolExecutor 25, ( ), tomcat .

, , ... ( tomcat 6.0 jdk 1.5.0_22)

0

Source: https://habr.com/ru/post/1767127/


All Articles