Hello,
We are using aspose to convert html to pdf, using Java. The conversion code is provided in the web application, deployed on the Tomcat web container.
It has been observed that when the application is undeployed or the Tomcat is shut down, the following is logged by Tomcat:
22-Oct-2020 14:11:05.779 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [webapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4da32f00]) and a value of type [com.aspose.pdf.internal.l4y.l0v] (value [com.aspose.pdf.internal.l4y.l0v@61a92b2c]) 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.
22-Oct-2020 14:11:05.779 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [webapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@28cb3010]) and a value of type [com.aspose.pdf.internal.imaging.system.Threading.Thread] (value [com.aspose.pdf.internal.imaging.system.Threading.Thread@46823c33]) 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.
22-Oct-2020 14:11:05.780 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [webapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@128dc0cc]) and a value of type [com.aspose.pdf.internal.l0k.lb] (value [com.aspose.pdf.internal.l0k.lb@3ad569fa]) 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.
22-Oct-2020 14:11:05.780 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [webapp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@4b6f9500]) and a value of type [com.aspose.pdf.internal.l57n.l1v] (value [com.aspose.pdf.internal.l57n.l1v@1c5b4bfa]) 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.
22-Oct-2020 14:11:05.780 SEVERE [main] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [webapp] created a ThreadLocal with key of type [com.aspose.pdf.internal.l29h.le$1] (value [com.aspose.pdf.internal.l29h.le$1@465710ea]) and a value of type [com.aspose.pdf.internal.l29h.le] (value [com.aspose.pdf.internal.l29h.le@158741]) 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.
This was reproduced on Windows 10 Enterprise and CentOS 7 OSes, Tomcat 9.0.19, Aspose 20.2 (and 20.10), Java 14.
Could you explain why this is logged, is it an issue to be fixed by aspose? Or can it be fixed by modifying our code?
The sample code used to convert html to pdf:
private byte[] getDocument()
{
byte[] result = null;
String htmlString = "<html><head><title>Title</title></head><body><p>Body</p></body></html>";
InputStream inputStream = new ByteArrayInputStream(htmlString.getBytes());
HtmlLoadOptions options = new HtmlLoadOptions();
options.setInputEncoding("UTF8");
Document document = new Document(inputStream, options);
try
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
document.save(outputStream);
result = outputStream.toByteArray();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
document.close();
document.dispose();
MemoryCleaner.clear();
MemoryCleaner.clearCurrentThreadLocals();
}
return result;
}
Thank you
Arjana Bivainiene