# ScheduledThreadPoolExecutor not shutting down completely

**URL:** <https://discuss.elastic.co/t/scheduledthreadpoolexecutor-not-shutting-down-completely/39504>\
**Category:** Elasticsearch\
**Created:** [January 19, 2016, 7:09am UTC](https://discuss.elastic.co/t/scheduledthreadpoolexecutor-not-shutting-down-completely/39504 "2016-01-19T07:09:13Z")\
**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 19, 2016, 7:09am UTC](https://discuss.elastic.co/t/scheduledthreadpoolexecutor-not-shutting-down-completely/39504/1 "2016-01-19T07:09:14Z")

</div>

I am using Elasticsearch 1.5.1 with Java application. I have been monitoring the application with plumbr tool.

Whenever JVM stop/redeploy is done, plumbr warns about Perm Gen memory leak issue.

Log indicates that ,  
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).

Can some one help if we can shutdown this ScheduledThreadPoolExecutor completely when JVM stops.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 19, 2016, 7:10am UTC](https://discuss.elastic.co/t/scheduledthreadpoolexecutor-not-shutting-down-completely/39504/2 "2016-01-19T07:10:19Z")

</div>

Please keep it to the one thread - [[Solved] Classloader Leak in Elasticsearch-ScheduledThreadPoolExecutor not cleared](https://discuss.elastic.co/t/classloader-leak-in-elasticsearch/39454)

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 19, 2016, 7:10am UTC](https://discuss.elastic.co/t/scheduledthreadpoolexecutor-not-shutting-down-completely/39504/3 "2016-01-19T07:10:22Z")

</div>


