Free Support Forum - aspose.com

Saving com.aspose.words.Document to PDF causes java.lang.OutOfMemoryError

Hi,

I'm using Aspose.Words 15.6.0 for jdk16 in *nix environment. Saving the Word document as PDF with source approximately size 177 Mb caused exception below:

invokeMethod() failed while calling: onaction Java heap space

java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferInt.(DataBufferInt.java:41)
at java.awt.image.Raster.createPackedRaster(Raster.java:458)
at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1015)
at java.awt.image.BufferedImage.(BufferedImage.java:321)
at asposewobfuscated.zzQ4.zzY(Unknown Source)
at asposewobfuscated.zzLZ.zzX(Unknown Source)
at asposewobfuscated.zzM0.zzZ(Unknown Source)
at asposewobfuscated.zzW.zzZ(Unknown Source)
at asposewobfuscated.zzW.zzZ(Unknown Source)
at asposewobfuscated.zzJ3.zzE(Unknown Source)
at asposewobfuscated.zzJ3.zzZ(Unknown Source)
at asposewobfuscated.zzK6.zzZ(Unknown Source)
at asposewobfuscated.zzK6.zzL(Unknown Source)
at asposewobfuscated.zzK8.endDocument(Unknown Source)
at asposewobfuscated.zzIF.endDocument(Unknown Source)
at com.aspose.words.zzZB7.zzZRr(Unknown Source)
at com.aspose.words.zz1A.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)


Please, clarify, does exist any restriction on file size for processing by Aspose.Words?

Hi Evgeny,


Thanks for your inquiry.

Sometimes Aspose.Words for Java will throw OutOfMemoryError on Java. This is because the default Java heap space might not be enough for high memory spikes when processing some documents. In this case, the easy way to workaround is to increase the heap space for the JVM.

Secondly, your source document is also very huge. I would advise you to use a few small documents instead of one huge document. You can try converting each small document to PDF format using Aspose.Words and then by using Aspose.Pdf merge these small PDF files into a single big PDF. For more information, please read the following link:

I hope, this helps.

Best regards,