# DeflateCompressor threads causing memory leak in Tomcat

**URL:** <https://discuss.elastic.co/t/deflatecompressor-threads-causing-memory-leak-in-tomcat/334769>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 31, 2023, 8:49am UTC](https://discuss.elastic.co/t/deflatecompressor-threads-causing-memory-leak-in-tomcat/334769 "2023-05-31T08:49:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KristianJ](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@KristianJ](https://discuss.elastic.co/u/KristianJ)\
**Post date:** [May 31, 2023, 8:49am UTC](https://discuss.elastic.co/t/deflatecompressor-threads-causing-memory-leak-in-tomcat/334769/1 "2023-05-31T08:49:42Z")

</div>

Hi,  
using ES 7.17.10 in a Tomcat container (9.0.x). When the application is shutdown there are two threads that are not removed, causing memory leaks from the DeflateCompressor class.

In particular it would seem that the close() method in DeflateCompressor is never called. I use a RestHighLevelClient . I call close() on the client, but still end up with this in the Tomcat logs:

`31-May-2023 10:31:20.686 SEVERE [Thread-3] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [gub-kat57] created a ThreadLocal with key of type [java.lang.ThreadLocal.SuppliedThreadLocal] (value [java.lang.ThreadLocal$SuppliedThreadLocal@676145c1]) and a value of type [org.elasticsearch.common.compress.DeflateCompressor.ReleasableReference] (value [org.elasticsearch.common.compress.DeflateCompressor$ReleasableReference@5e85e241]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.`

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 31, 2023, 9:06am UTC](https://discuss.elastic.co/t/deflatecompressor-threads-causing-memory-leak-in-tomcat/334769/2 "2023-05-31T09:06:53Z")

</div>

Welcome!

Which client are you using? If not the [new Java Client](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html), could you switch to this one?

---

<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:** [June 28, 2023, 9:07am UTC](https://discuss.elastic.co/t/deflatecompressor-threads-causing-memory-leak-in-tomcat/334769/3 "2023-06-28T09:07:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
