we are currently trying to convert a simple PDF to PDF/A with Aspose.PDF.
Sadly we are not successful, because of OutOfMemory-Issues.
Code:
OptimizedMemoryStream ms = new OptimizedMemoryStream(Files.readAllBytes(pdfFile.toPath()));
try (com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(ms);
// just write the first Bytes of the protocol
FixedSizeByteArrayOutputStream logStream = new FixedSizeByteArrayOutputStream(ASPOSE_LOG_MAX_LENGTH)) {
// ⚡ OOM
boolean convertResult = pdfDocument.convert(logStream, PdfFormat.PDF_A_1B, ConvertErrorAction.Delete, ConvertTransparencyAction.Default);
if (convertResult) {
pdfDocument.save(convertedPdf.getAbsolutePath());
}
} finally {
ms.close();
}
Attached you find our PDF-File.
Profiling this method leads to memory-usage von ~8GB. Do you have any tips to reduce the amount of RAM?
For our customers we need to aim to PDF files with ~200MB in size.
Can you please share which JDK version are you using as well as what is the Java Heap Size set in your environment? Please try with 24.9 version as well and let us know what results you got by sharing screenshot of memory consumption. We will log an investigation ticket to address this case accordingly.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFJAVA-44447
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
I am a bit puzzled, that we pay for a Licence and the only help is “we created an issue”.
Can you confirm, that I have used your API in the right way?
Furthermore, I have found a thread mentioning the MemoryExtender-Class: How to use MemoryExtender
Can you adjust my code, that it use this class in hope, it will make the convert more memory-efficient?
I tried and the Method “isSwapEnabled()” is never called in testcases.
The previous message was an automated response generated by our system when ticket was attached to this forum thread. The ticket has been generated in our issue tracking system for the analysis of your case and investigate the reasons behind this behavior of the API. We will look into the details of the ticket and let you know as soon as the ticket is resolved.
The code snippet that you are using seems fine and we could not find any suggestion or adjustments to share at the moment after an initial investigation. Once the ticket is analyzed by our development team, we will be able to share more insights with you.
Related to the MemoryExtender Class, you can simply call below method after the document initialization to check if it improves the results.
Thanks for sending the information in a private message. We have updated the ticket information accordingly and will inform you as soon as we make some updates. Please spare us some time.