Out of Heap Space on PDF Image creation

We are currently getting the following stack trace when attempting to produce an image from pdf to add custom branding for a production. Is there any method that we could use to help with heap space consumption in order not to have to increase resources to complete process? The pdf file contains a blueprint or a combination of multiple blueprints.

Stack Trace:

java.lang.OutOfMemoryError: Java heap space
java.util.Arrays.copyOf(Arrays.java:3332)
java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
java.lang.StringBuilder.append(StringBuilder.java:136)
com.aspose.pdf.internal.l0h.ld.lI(Unknown Source)
com.aspose.pdf.OperatorCollection.toString(Unknown Source)
com.aspose.pdf.OperatorCollection.updateNormalizedData(Unknown Source)
com.aspose.pdf.facades.APdfFileEditor.resizeContents(Unknown Source)
com.aspose.pdf.facades.PdfFileEditor.resizeContents(Unknown Source)
com.aspose.pdf.facades.APdfFileEditor.resizeContentsWithNormalization(Unknown Source)
com.aspose.pdf.facades.PdfFileEditor.resizeContentsWithNormalization(Unknown Source)
com.stormed.common.utils.ImageUtils.brandPdf(ImageUtils.java:1082)
com.stormed.production.ProductionMain.doBranding(ProductionMain.java:436)
com.stormed.production.ProductionMain.(ProductionMain.java:129)
com.stormed.production.common.ProductionBuilder.run(ProductionBuilder.java:27)
com.stormed.proxy.AppRunner.run(AppRunner.java:21)
com.stormed.proxy.ProxyMain.runApp(ProxyMain.java:274)
com.stormed.proxy.ProxyMain.lambda$main$0(ProxyMain.java:122)
com.stormed.proxy.ProxyMain$$Lambda$73/1165449749.call(Unknown Source)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

@dmckinney

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input PDF.
  • Please share your working environment.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.