GroupDocs.Viewer creates a bunch of locked aspose.temp files in temp folder

GroupDocs.Viewer creates a bunch of locked aspose.temp files in the temp folder. This is a concern because those files are occupying unnecessary disk space and we cannot delete them because they are locked, meaning the resource was not released causing a memory leak. When we shut down the server we can delete the files.

Git project: GitHub - groupdocs-viewer/GroupDocs.Viewer-for-Java: GroupDocs.Viewer for Java examples, plugins and showcase
Git branch: master
Git revision: ddcf8944
SO: Windows 10
Java version: Redhat OpenJDK 11.0.10
Server: Apache Tomcat 9.0.50
Documents: gd21-link-table-encode-pdf.pdf (182.2 KB)
Screenshots: gd viewer creates bunch of aspose temp files.png (110.1 KB)
gd21-link-table-encode-pdf.pdf (182 KB)
gd viewer creates bunch of aspose temp files.png (110 KB)

@john.mcqueide

Thank you for attaching the sample file and screenshot. We’re looking into this issue and update you as soon as we have any information.

1 Like

@john.mcqueide

When processing the PDF documents we’re creating temporary files with the mask aspose_ ***.tmp. These temporary files that are not locked by JVM can be removed using com.groupdocs.viewer.Viewer.clearTempFiles(); static method. For example, clearTempFiles method can be called before each next file rendering loadDocument method of ViewerServiceImpl class to remove temporary files that haven’t been removed automatically after the previous rendering. Because the temp files are locked by JVM it is safe to call this method during file rendering.

Looking forward to your feedback.

1 Like

@john.mcqueide

As an addition to my previous comment, please note that we use java.awt when working with system fonts and the following method works in such way (creates temp files and track them):

java.awt.Font.createFont(int fontFormat, InputStream fontStream)
java.awt.Font.createFont(int fontFormat, java.io.File fontFile)

The temp files will be deleted by JVM with using ShutdownHook when the program exits normally.
https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)

1 Like

@vladimir.litvinchik Thanks for your answer. I tried to reproduce the issue again but I was not able to, I will try using com.groupdocs.viewer.Viewer.clearTempFiles(); if it happens again.

@john.mcqueide

Ok, thank you for the response.