FrameworkException: Not enough memory to process jpeg file

Hi Team,
We are facing “Not enough memory to process jpeg file.” exception while converting images(multi-page tiff file) to PDF.

Please find the below complete error.
com.aspose.pdf.internal.ms.System.l8u: FrameworkException: Not enough memory to process jpeg file. at com.aspose.pdf.internal.l60f.lf.(Unknown Source) at com.aspose.pdf.internal.l60f.lf.(Unknown Source) at com.aspose.pdf.internal.l63p.lk.lI(Unknown Source) at com.aspose.pdf.internal.l63p.lj.write(Unknown Source) at javax.imageio.ImageWriter.write(ImageWriter.java:597) at com.aspose.pdf.internal.l58y.lI.lI(Unknown Source) at com.aspose.pdf.internal.l58y.lI.lf(Unknown Source) at com.aspose.pdf.internal.l58y.lI.lf(Unknown Source) at com.aspose.pdf.internal.l58y.lI.lI(Unknown Source) at com.aspose.pdf.internal.l55t.lf.lI(Unknown Source) at com.aspose.pdf.internal.l55t.l1v.lI(Unknown Source) at com.aspose.pdf.internal.l55t.l1v.lI(Unknown Source) at com.aspose.pdf.internal.l55t.l1v.lI(Unknown Source) at com.aspose.pdf.Image.lI(Unknown Source) at com.aspose.pdf.l12if.lI(Unknown Source) at com.aspose.pdf.l12if.le(Unknown Source) at com.aspose.pdf.Page.lf(Unknown Source) at com.aspose.pdf.Page.lc(Unknown Source) at com.aspose.pdf.ADocument.processParagraphs(Unknown Source) at com.aspose.pdf.Document.processParagraphs(Unknown Source) at com.aspose.pdf.ADocument.lf(Unknown Source) at com.aspose.pdf.ADocument.lf(Unknown Source) at com.aspose.pdf.ADocument.save(Unknown Source) at com.aspose.pdf.Document.save(Unknown Source) at com.stormed.common.utils.ImageUtils.imageFileToPdfAspose(ImageUtils.java:256) at com.stormed.common.utils.ImageUtils.imageMergeToPDF(ImageUtils.java:771) at com.stormed.common.utils.ImageUtils.convertImagesToPDF(ImageUtils.java:821) at com.stormed.production.ProductionMain.(ProductionMain.java:87) at com.stormed.production.common.ProductionBuilder.run(ProductionBuilder.java:27) at com.stormed.proxy.AppRunner.run(AppRunner.java:19) at com.stormed.proxy.ProxyMain.runApp(ProxyMain.java:274) at com.stormed.proxy.ProxyMain.lambda$main$0(ProxyMain.java:122) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.OutOfMemoryError: Java heap space

We are using below versions of aspose.

        [group: 'com.aspose', name: 'aspose-pdf', version: '23.1'],
        [group: 'com.aspose', name: 'aspose-imaging', version: '22.7'<a class="attachment" href="/uploads/default/77594">1doc10kpages2.zip</a> (63.4 KB)

],1doc10kpages2.zip (63.4 KB)

@ashokreddyd Thank you for reaching out to us regarding your concern. We have received your inquiry and would like to assure you that we will thoroughly investigate the matter and come back to you with an answer as soon as possible. Thank you for your patience and understanding.

@ashokreddyd We have tested your file and were unable to open it using either our Aspose.Imaging product or tools such as https://convert.io/, TIFF viewer -- Online Cloud File Viewer, IrfanView, ACDSee. What did you use to open the file and what code did you use to try to load the file?

@Alexey.Karpenko Thank you for your quick response.

Please find the steps below and enclosed attachment.

  1. Fetching all the documents to merge using below statement.
    for (String imageFilePath : singlePageFilePathListiff_merge_to_pdf.7z (1.4 MB)
    t) { // singlePageFilePathList will have documents path list
  2. Reading each image using the statement.
    java.awt.image.BufferedImage image = ImageIO.read(new File(inputFilePath));
  3. Create Document object save document to output path
    Document pdfDocument = new Document();
    com.aspose.pdf.Image image1 = new com.aspose.pdf.Image();
    image1.setBufferedImage(image);
    page.getParagraphs().add(image1);
  4. Using below statement to merge all the files.
    String pdfFilePath = imageFilePath.substring(0, imageFilePath.lastIndexOf(’.’)) + “.pdf”;
    List pdfFileList = new ArrayList<>();
    pdfFileList.add(pdfFilePath);
    new com.aspose.pdf.facades.PdfFileEditor().concatenate(pdfFileList.toArray(new String[0]), outFilePath);

@ashokreddyd Got it. Your request is related to Aspose.PDF, not Aspose.Imaging. Therefore, I have moved this topic to the correct team’s forum section.

@ashokreddyd

Would you please share the complete code snippet for our reference so that we can test the scenario accordingly and address it? Also, please try to use 23.4 version of the API before sharing the code snippet.

Hi Aspose Team,

I am also continuing this conversation that @ashokreddyd started about this issue. Thanks for the assistance so far. I have followed your suggestion and upgraded our Aspose version to 23.4 and ran the same test with the 1doc10kpages file again. For this particular issue, I am still getting the “Not enough memory to process jpeg file” error when processing JPEG to PDF.

Aspose.PDF now at 23.4

[group: 'com.aspose', name: 'aspose-pdf', version: '23.4']

Can you please advise next steps to remediate this issue?
I’m also happy to get on a call to discuss as well if that is easier.

@ashokreddyd

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-42791

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.

Thank you so much for escalating the issue.

If you can keep us updated on the status of the internal ticket, that would be great.

I’ll ask my manager to see if we need to take advantage of the Paid Support Services.

HI @asad.ali

I also wanted to bring your attention to a previous post that was made by my colleagues in 2021 about a memory leak for converting TIFF to PDF. Here is the link:

We’re now using Java 17, Amazon Coretto Edition. There is also a corresponding internal ticket PDFJAVA-40715Would this help in moving towards a solution?

@vcaspose

We will link both tickets and consider these both cases related. We have also updated the ticket information accordingly in our issue management system. We will further inform you once we make some progress towards ticket resolution.

@asad.ali

Thank you! Please keep me updated. Let me know if you need anything from me.

@vcaspose

Sure, we will let you know in case we need some information from your side during ticket investigation.

Hi @asad.ali

Any updates from your dev team on this issue?

Thank you

@vcaspose

Since the ticket was logged recently, it is pending for analysis. We will investigate it on a first come first serve basis and as soon as we have some updates in this regard, we will inform you. Please spare us some time.

We are sorry for the inconvenience.

Thank you @asad.ali

Please do let us know when you have an update.

@vcaspose

Sure, we will inform you.

@asad.ali has there been any updates on this?

@vcaspose

We are sorry that the ticket has not been yet resolved due to other issues in the queue. As soon as we make some progress towards ticket resolution, we will let you know in this forum thread. Please be patient and spare us some time.

We are sorry for the inconvenience.

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