Memory is leaked when Java web application is un-deployed at Apache Tomcat 9.0.20

Hi,

I use aspose to convert docx document to pdf document.
My code is quite simple (from the documentation) :

public void convertDocxToPdf(String docPathName, String finalPathPdf) {

    System.out.println("CONVERT - SOURCE: " + docPathName);
    System.out.println("CONVERT - TARGET PDF: " + finalPathPdf);
    try {
        //-- Open Document as Aspose document
        com.aspose.words.Document wpd = new com.aspose.words.Document(docPathName);
        //-- Convert to PDF
        wpd.save(finalPathPdf, SaveFormat.PDF);
    }
    catch(Exception e) {
        e.printStackTrace();
    }
}

Everything seems to be OK (daily usage) but when I undeployed the war from the tomcat yesterday night I get some frightening warning/error :
21-Oct-2020 23:15:46.553 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zzP8$1] (value [com.aspose.words.internal.zzP8$1@4cd46986]) and a value of type [com.aspose.words.internal.zzFD] (value [com.aspose.words.internal.zzFD@5cc6b71e]) 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.
21-Oct-2020 23:15:46.554 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@1698996d]) and a value of type [com.aspose.words.internal.zz1P] (value [white]) 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.
21-Oct-2020 23:15:46.554 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@504eef8e]) and a value of type [com.aspose.words.internal.zz1P] (value [NUMPAGES]) 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 appears multiple times in the catalina logs when undeployed).

Can you help me ?

Jonathan

@jokamax

Please use the latest version of Aspose.Words for Java 20.9 and let us know how it goes on your end. If you still face problem, please ZIP and attach your input Word document here for testing. We will investigate the issue and provide you more information on it.

HI,

I’m already in version 20.9. Cf. my pom.xml :

<dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-words</artifactId>
            <version>20.9</version>
            <type>pom</type>
</dependency>

Please find enclose the doc file use.

doctotest.zip (282.4 KB)

We use deploy/undeploy from tomcat manager : http://XXX:8080/manager/html
On “undeployed” : a looooooot of error like that :

21-Oct-2020 23:15:46.553 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zzP8$1] (value [com.aspose.words.internal.zzP8$1@4cd46986]) and a value of type [com.aspose.words.internal.zzFD] (value [com.aspose.words.internal.zzFD@5cc6b71e]) 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.
21-Oct-2020 23:15:46.554 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@1698996d]) and a value of type [com.aspose.words.internal.zz1P] (value [white]) 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.
21-Oct-2020 23:15:46.554 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@504eef8e]) and a value of type [com.aspose.words.internal.zz1P] (value [NUMPAGES]) 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.
21-Oct-2020 23:15:46.554 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@4afa2bf]) and a value of type [com.aspose.words.internal.zz1P] (value []) 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.
21-Oct-2020 23:15:46.555 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zzP8$1] (value [com.aspose.words.internal.zzP8$1@4cd46986]) and a value of type [com.aspose.words.internal.zzFD] (value [com.aspose.words.internal.zzFD@6f6db209]) 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.
21-Oct-2020 23:15:46.555 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@1698996d]) and a value of type [com.aspose.words.internal.zz1P] (value [white]) 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.
21-Oct-2020 23:15:46.555 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@504eef8e]) and a value of type [com.aspose.words.internal.zz1P] (value [NUMPAGES]) 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.
21-Oct-2020 23:15:46.555 SEVERE [http-nio-8081-exec-760] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [crm] created a ThreadLocal with key of type [com.aspose.words.internal.zz1N$1] (value [com.aspose.words.internal.zz1N$1@4afa2bf]) and a value of type [com.aspose.words.internal.zz1P] (value []) 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.

@jokamax

Thanks for sharing the detail. Please share the WAR file that you are using to reproduce this issue at our end. Please also share the Tomcat version. We will investigate this issue and provide you more information on it.

Hi,

Tomcat/Appache : Apache Tomcat/9.0.20
JVM : 12.0.1+12

But impossible to share the WAR… This is a production product war !

If you can’t just reproduce with a simple POC + my word file : can you maybe explain me how to debug your librairy ?

Jonathan

@jokamax

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSJAVA-2480. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Thanks a lot

Hi,

Nothing new about : WORDSJAVA-2480 ?

Thanks,

Jonathan

@jokamax

We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

A post was split to a new topic: Aspose.Words for Java memory leak issue when undeploy WAR file