PDF to Image Java using Aspose.PDF - OutOfMemoryException

@UpperVolta

We apologize for the delay in resolution of the earlier logged ticket. Please note that we do resolve every logged issue. However, resolution time of the issue depends upon many factors to be noticed like the issue complexity and nature and number of API components involve in it. Nevertheless, your concerns have been recorded and we will consider them during ticket analysis process. We will inform you as soon as we make some progress towards ticket fix. Your patience is highly appreciated in this regard.

We apologize for the inconvenience.

The issues you have found earlier (filed as PDFJAVA-41255) have been fixed in Aspose.PDF for Java 23.5.

I downloaded aspose-pdf-23.5 and tried the same source and sample PDF that I provided to you when I opened the issue. The issue is not resolved. The program uses 5 GB of memory and 100% cpu and never completes. At least it has not completed so far and it has been running two hours.

Why was this issue closed?

@UpperVolta

We have optimized the process and now 2.5 GB (-Xmx2560M) of RAM is enough for the successful execution of the code.

In addition, you need to enable swap: MemoryExtender.setSwapEnabled(true);

MemoryExtender.setSwapEnabled(true);
Document pdfDocument = new Document(dataDir + "QwuA2vRdX9.pdf");
for (Page page : pdfDocument.getPages()) {
 int number = page.getNumber();
 java.io.OutputStream imageStream = new java.io.FileOutputStream(dataDir + "Converted_Image_"+page.getNumber()+".png");
 com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(100);
 com.aspose.pdf.devices.PngDevice pngDevice = new com.aspose.pdf.devices.PngDevice(resolution);
 pngDevice.process(page, imageStream);
 imageStream.close();
}