Author: centic
Date: Sat Mar 11 09:53:39 2023
New Revision: 1908266
URL: http://svn.apache.org/viewvc?rev=1908266&view=rev
Log:
Add FAQ entry for thread-locals and how to clear them
Modified:
poi/site/publish/help/faq.html
poi/site/src/documentation/content/xdocs/help/faq.xml
Modified: poi/site/publish/help/faq.html
URL:
http://svn.apache.org/viewvc/poi/site/publish/help/faq.html?rev=1908266&r1=1908265&r2=1908266&view=diff
==============================================================================
--- poi/site/publish/help/faq.html (original)
+++ poi/site/publish/help/faq.html Sat Mar 11 09:53:39 2023
@@ -797,6 +797,27 @@ and
-Xjit:exclude={sun/java2d/pipe/AAShapePipe.renderTiles(Lsun/java2d/SunGraphics2D;Ljava/awt/Shape;Lsun/java2d/pipe/AATileGenerator;[I)V},exclude={sun/java2d/pipe/AlphaPaintPipe.renderPathTile(Ljava/lang/Object;[BIIIIII)V},exclude={java/awt/TexturePaintContext.getRaster(IIII)Ljava/awt/image/Raster;}
</pre>
</div>
+<a name="faq-thread-local-memory-leaks"></a>
+<h2 class="boxed">26.
+ Tomcat is reporting memory leaks caused by some class in Apache
POI which uses ThreadLocal
+ </h2>
+<div class="section">
+<p>Apache POI uses Java <a
href="https://docs.oracle.com/javase/8/docs/api/java/lang/ThreadLocal.html">ThreadLocals</a>
+ in order to cache some data when Apache POI is used in a
multi-threading environment (see also the FAQ about thread-safety above!)
+ </p>
+<p>WebServers like Tomcat use thread-pooling to re-use threads to avoid the
cost of frequent thread-startup and shutdown.
+ In order to guard against memory-leaks, Tomcat performs checks
on allocated memory in ThreadLocals and reports them as warnings.
+ </p>
+<p>In order to get rid of these warnings, Apache POI, starting with version
5.2.4, provides a utility ThreadLocalUtils which can
+ be used to clear all objects held in thread-local objects
before returning the thread back to the global pool.
+ </p>
+<pre class="code">
+ org.apache.poi.util.ThreadLocalUtil.clearAllThreadLocals();
+
+ // if you use poi-ooxml, also clear thread-locals in XMLBeans
+ org.apache.xmlbeans.ThreadLocalUtil.clearAllThreadLocals();
+ </pre>
+</div>
</div>
<!--+
|end content
Modified: poi/site/src/documentation/content/xdocs/help/faq.xml
URL:
http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/help/faq.xml?rev=1908266&r1=1908265&r2=1908266&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/help/faq.xml (original)
+++ poi/site/src/documentation/content/xdocs/help/faq.xml Sat Mar 11 09:53:39
2023
@@ -675,4 +675,26 @@ and
</source>
</answer>
</faq>
+ <faq id="faq-thread-local-memory-leaks">
+ <question>
+ Tomcat is reporting memory leaks caused by some class in Apache
POI which uses ThreadLocal
+ </question>
+ <answer>
+ <p>Apache POI uses Java <a
href="https://docs.oracle.com/javase/8/docs/api/java/lang/ThreadLocal.html">ThreadLocals</a>
+ in order to cache some data when Apache POI is used in a
multi-threading environment (see also the FAQ about thread-safety above!)
+ </p>
+ <p>WebServers like Tomcat use thread-pooling to re-use threads to
avoid the cost of frequent thread-startup and shutdown.
+ In order to guard against memory-leaks, Tomcat performs checks
on allocated memory in ThreadLocals and reports them as warnings.
+ </p>
+ <p>In order to get rid of these warnings, Apache POI, starting
with version 5.2.4, provides a utility ThreadLocalUtils which can
+ be used to clear all objects held in thread-local objects
before returning the thread back to the global pool.
+ </p>
+ <source>
+ org.apache.poi.util.ThreadLocalUtil.clearAllThreadLocals();
+
+ // if you use poi-ooxml, also clear thread-locals in XMLBeans
+ org.apache.xmlbeans.ThreadLocalUtil.clearAllThreadLocals();
+ </source>
+ </answer>
+ </faq>
</faqs>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]