Hi,
we are facing potential memory leak in aspose.pdf library when converting pdf to pptx. Looks like memory leak is outside JVM, as both heap and non-heap (inspected with native memory tracker) memory is stable during runtime.
Tested with aspose.pdf versions 22.2, 24.8
Reproducible both in linux and windows operating systems.
Code snippet:
private static final Executor EXECUTOR = Executors.newFixedThreadPool(3);
public static void main(String[] args) throws Exception {
new com.aspose.pdf.License().setLicense(args[0]);
for (int i = 0; i < 1000; i++) {
CompletableFuture.runAsync(Pdf2PptxSimple::runExportTask, EXECUTOR);
}
}
private static void runExportTask() {
try {
try (InputStream pdf = Pdf2PptxSimple.class.getClassLoader().getResourceAsStream("document.pdf")) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (Document srcDoc = new Document(pdf)) {
srcDoc.save(out, SaveFormat.Pptx);
System.out.println(out.size());
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
With 2G heap limit (-Xmx2g) total memory usage:
- after 100 exports ~3.5G
- after 200 exports ~4.5G
- after 450 exports ~7G
Please find the full working example and PDF document attached.
pdf2pptx.zip (125.2 KB)
document.pdf (503.7 KB)