# \[Solved\] Classloader Leak in Elasticsearch-ScheduledThreadPoolExecutor not cleared

**URL:** <https://discuss.elastic.co/t/solved-classloader-leak-in-elasticsearch-scheduledthreadpoolexecutor-not-cleared/39454>\
**Category:** Elasticsearch\
**Created:** [January 18, 2016, 2:02pm UTC](https://discuss.elastic.co/t/solved-classloader-leak-in-elasticsearch-scheduledthreadpoolexecutor-not-cleared/39454 "2016-01-18T14:02:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArivazhaganJ](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ArivazhaganJ](https://discuss.elastic.co/u/ArivazhaganJ)\
**Post date:** [January 18, 2016, 2:02pm UTC](https://discuss.elastic.co/t/solved-classloader-leak-in-elasticsearch-scheduledthreadpoolexecutor-not-cleared/39454/1 "2016-01-18T14:02:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ArivazhaganJ](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@ArivazhaganJ](https://discuss.elastic.co/u/ArivazhaganJ)\
**Post date:** [January 20, 2016, 7:12am UTC](https://discuss.elastic.co/t/solved-classloader-leak-in-elasticsearch-scheduledthreadpoolexecutor-not-cleared/39454/2 "2016-01-20T07:12:02Z")

</div>

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](http://stackoverflow.com/questions/34857591/shutdown-scheduledthreadpoolexecutor-opened-by-3rd-party-jar-during-jvm-stop)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:23pm UTC](https://discuss.elastic.co/t/solved-classloader-leak-in-elasticsearch-scheduledthreadpoolexecutor-not-cleared/39454/3 "2017-07-05T23:23:09Z")

</div>


