[Solved] Classloader Leak in Elasticsearch-ScheduledThreadPoolExecutor not cleared


(Arivazhagan Jeganathan) #1

Following are the logs from **Plumbr** tool:

The memory leak detected is caused by a programming error.
The following information indicates the location of the leak in the source code
Leaked classloader
org.apache.catalina.loader.WebappClassLoader
Your application leaks classloaders because the application has not shut down the java.util.concurrent.ScheduledThreadPoolExecutor thread pool before the redeploy. This thread pool has 1 tasks in queue waiting to be executed and 1 threads currently running.
pool-11-thread-1
See below to find out, what are threads from this pool doing right now.
1 threads run:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:226)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2082)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1090)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:807)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
java.lang.Thread.run(Thread.java:722)

I have invoked client.close() and also added client.threadpool().scheduler().shutdown() and client.threadpool().shutdown(). [ tried shutdownNow() methods also).
But still facing the error.

Help me on how to shutdown the ThreadPool/ExecutorService opened by elasticsearch in my web application?


ScheduledThreadPoolExecutor not shutting down completely
(Arivazhagan Jeganathan) #2

My apology. First of all, the thread causing class loader leak is caused by Mongo client not being closed.

Fixed this class loader leak , reference article:
http://stackoverflow.com/questions/34857591/shutdown-scheduledthreadpoolexecutor-opened-by-3rd-party-jar-during-jvm-stop


(system) #3