640MB RAM Usage during PPT to PDF Conversion in Java for a 4MB PPT File

Recently we use this PPT file (because Forum doesn’t allow PPT file, so I zip it as 7z) to test Aspose PPT2PDF, our code is very simple

//Usage: excel2pdf("source.xlsx", "target.pdf")
public static void excel2pdf(String excelFilename, String targetPDFname)
{
    try
    {
        final Workbook workbook = new Workbook(excelFilename);
        workbook.save(targetPDFname);
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

However, during test, the RAM usage of this test file is 640 MB. Is it normal?

[2023-09-26 14:45:04.784 @ 60868 / 466432] ERROR [AsposeConverter] : .convertToPDF(): Throwable occured.
java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferByte.(DataBufferByte.java:76) ~[?:1.8.0_232]
at java.awt.image.Raster.createInterleavedRaster(Raster.java:266) ~[?:1.8.0_232]
at java.awt.image.BufferedImage.(BufferedImage.java:391) ~[?:1.8.0_232]
at com.aspose.slides.internal.wl.t8.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.internal.wl.t8.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.internal.wl.t8.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.internal.vr.t8.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.internal.vr.t8.(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.bcy.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.bcy.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.Picture.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.fbj.(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.cn.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.cn.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.qhv.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.qhv.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.ok4.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.ev.sj(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.ev.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.zuh.t8(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.zuh.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.zuh.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.zuh.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.Slide.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.vfa.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.vfa.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.Presentation.b6(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at com.aspose.slides.Presentation.save(Unknown Source) ~[aspose-slides-23.7-jdk16.jar:23.7]
at ff.converter.helper.AsposeHelper.convertPptToPDF(AsposeHelper.java:181)

@zwei,
Thank you for contacting support.

Unfortunately, you were unable to upload the archive file with the sample presentation. Please try again.

Your code example is intended to convert Excel files. Please share the code example you used to convert PowerPoint presentations.

sorry, my bad in last post…

here it is our ppt2pdf code

//Usage: ppt2pdf("source.ppt", "target.pdf");
public static void ppt2pdf(String pptFilename, String targetPDFname)
{
    final Presentation presentation = new Presentation(pptFilename);
    presentation.save(targetPDFname, com.aspose.slides.SaveFormat.Pdf);
}

and here it is the ppt file in 7z format
forprocess_anwendungsmanager_praesentation_16zu9.7z (4,0 MB)

@zwei,
Thank you for the code example and presentation file. I will get back to you as soon as possible.

1 Like

@zwei,
Please share the following additional information:

  • OS version on which the problem occurs
  • JDK version in your app

Open JDK 64
JAVA_VERSION=“1.8.0_232”
OS_ARCH=“amd64”

Microsoft Windows [Version 10.0.14393]

@zwei,
Thank you for the additional information.

The presentation contains 125 different images. Typically images take up more memory than their size. For example, a 456Kb (1110 x 530 pixels) image on a disc is not equal to 456Kb in RAM, because images are compressed on the disc. An image usually uses 4 Bytes Per Pixel, the formula for calculating RAM is like this: height * width * BPP, in our case 1110 * 530 * 4 = 2 353 200.

In addition, images in some cases need to be adapted to the size of the slide, for this need to draw them in other sizes, in fact, multiplying by 2 the required memory to store these images.

Unfortunately, there is no solution that will definitely prevent OOM from occurring. We suggest using IBlobManagementOptions as follows:

LoadOptions loadOptions = new LoadOptions();
loadOptions.getBlobManagementOptions().setPresentationLockingBehavior(PresentationLockingBehavior.KeepLocked);
loadOptions.getBlobManagementOptions().setTemporaryFilesAllowed(true);
loadOptions.getBlobManagementOptions().setTempFilesRootPath(resourcesOutputPath);
loadOptions.getBlobManagementOptions().setMaxBlobsBytesInMemory(100000000);

Presentation presentation = new Presentation("forprocess_anwendungsmanager_praesentation_16zu9.pptx", loadOptions);
1 Like

Thank you very much!

@zwei,
Thank you for using Aspose.Slides.

1 Like