Aspose.PDF java.lang.OutOfMemoryError: Java heap space

Hi,

I am developing a lambda function that uses Aspose.PDF to convert a single page PDF to an image format, either JPEG or TIFF and keep running into an OOM exception randomly at com.aspose.pdf.Page.getColorType(). I am running on 3008MB ram AWS lambda function running in a container and our deployment pipeline keeps failing randomly with these OOM errors and when running integration tests locally. I have tried JVM options to increase memory but still the same issues. Also when we are running the lambda and it is working it tends to hang on certain requests and Iā€™m assuming it is running out of memory but no matter how high I put the lambda resources it still happens. Any help in solving this issue would be greatly appreciated. Please let me know if you need more info.

Thank you!

java:
image: amazoncorretto:11

com.amazonaws:aws-java-sdk-s3:1.11.529
com.amazonaws:aws-lambda-java-core:1.2.0
com.amazonaws:aws-java-sdk-lambda:1.11.529

Aspose PDF com.aspose:aspose-pdf:23.2:jdk17

Stack Trace:

java.lang.OutOfMemoryError: Java heap space
at com.aspose.pdf.internal.ms.System.IO.l1j.lI(Unknown Source)
at com.aspose.pdf.internal.ms.System.IO.l1j.lj(Unknown Source)
at com.aspose.pdf.internal.ms.System.IO.l1j.writeByte(Unknown Source)
at com.aspose.pdf.internal.l7f.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l7if.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l7if.lt.lf(Unknown Source)
at com.aspose.pdf.internal.l3if.lt.(Unknown Source)
at com.aspose.pdf.internal.l3if.lt.lI(Unknown Source)
at com.aspose.pdf.internal.l5t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l5t.lI.lI(Unknown Source)
at com.aspose.pdf.internal.l3k.l0h.lf(Unknown Source)
at com.aspose.pdf.internal.l3k.l0h.lt(Unknown Source)
at com.aspose.pdf.internal.l3k.lu.lf(Unknown Source)
at com.aspose.pdf.internal.l3k.lu.lI(Unknown Source)
at com.aspose.pdf.devices.lI.lI(Unknown Source)
at com.aspose.pdf.devices.lI.lI(Unknown Source)
at com.aspose.pdf.devices.ImageDevice.lI(Unknown Source)
at com.aspose.pdf.devices.PngDevice.processInternal(Unknown Source)
at com.aspose.pdf.internal.l10k.lf.lI(Unknown Source)
at com.aspose.pdf.internal.l10k.lf.lI(Unknown Source)
at com.aspose.pdf.Page.getColorType(Unknown Source)
at com.csdisco.pdftoimage.process.AsposeImageProcessor.detectColor(AsposeImageProcessor.java:56)
at com.csdisco.pdftoimage.process.AbstractImageProcessor.processImage(AbstractImageProcessor.java:37)
at com.csdisco.pdftoimage.Handler.myHandleRequest(Handler.java:62)
at com.csdisco.pdftoimage.Handler.myHandleRequest(Handler.java:30)
at com.csdisco.ss_file_services.lambda.FileServicesLambdaHandler.handleRequestImpl(FileServicesLambdaHandler.java:174)
at com.csdisco.ss_file_services.lambda.FileServicesLambdaHandler.handleRequestImpl(FileServicesLambdaHandler.java:35)
at com.csdisco.lambda.scaffolding.BaseHandler.handleRequest(BaseHandler.java:62)
at com.csdisco.ss_file_services.lambda.utilities.StreamTestingUtilities.handlePayloadToOutputStream(StreamTestingUtilities.java:28)

@ehenry120

Have you tried using 23.7 version of the API? If issue still persists, please share your sample document and the code snippet with us for our reference. We will test the scenario in our environment and address it accordingly.

I found out it was the gradle daemon running out of memory running multiple tests.

1 Like