gvaysman-at-github opened a new issue, #12000: URL: https://github.com/apache/lucene/issues/12000
### Description When the web application that uses Lucene Facets is shut down (say, from Tomcat Manager app), ThreadLocal<BytesRefBuilder> from UTF8TaxonomyWriterCache (the field bytes) is never cleaned up. As a result, not only Tomcat complains of possible thread leak, the heap dump confirms this (below). The code examination (including the latest lucene-facet 9.4.2) shows no bytes.remove() anywhere. Just clearing the BytesRefBuilder internal array is not sufficient. Tomcat outputs to the console the following: SEVERE [Thread-213] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [mh] created a ThreadLocal with key of type [org.apache.lucene.facet.taxonomy.writercache.UTF8TaxonomyWriterCache$1] (value [org.apache.lucene.facet.taxonomy.writercache.UTF8TaxonomyWriterCache$1@4c6f99ab]) and a value of type [org.apache.lucene.util.BytesRefBuilder] (value [Unknown]) 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. Heap dump shows that the web app class loader, with all statics, etc. (unrelated to Lucene), cannot be released because of this leak  ### Version and environment details _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org