OutOfMemory has occured

Hi,

we got this exception while insert data of 2 CSV files into mergefields of 2 Word documents and combine them.
Now we are using 'Aspose.Words for Java 10.8.0.0'.
Stack trace is:

******************************************************************************************
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at asposewobfuscated.xy.dH(MemoryStream.java:194)
at asposewobfuscated.xy.dG(MemoryStream.java:158)
at asposewobfuscated.xy.write(MemoryStream.java:363)
at asposewobfuscated.zj.write(JavaOutputStream.java:47)
at asposewobfuscated.acv.write(UTF8Writer.java:143)
at asposewobfuscated.adq.flushBuffer(BufferingXmlWriter.java:1366)
at asposewobfuscated.adq.bd(BufferingXmlWriter.java:1377)
at asposewobfuscated.adq.a(BufferingXmlWriter.java:900)
at asposewobfuscated.ado.l(BaseNsStreamWriter.java:508)
at asposewobfuscated.ado.ah(BaseNsStreamWriter.java:228)
at asposewobfuscated.yx.c(XmlTextWriter.java:322)
at asposewobfuscated.e.c(AnyXmlBuilder.java:207)
at com.aspose.words.adi.ae(NrxXmlBuilder.java:90)
at com.aspose.words.acw.a(NrxRunPrWriter.java:533)
at com.aspose.words.acw.a(NrxRunPrWriter.java:58)
at com.aspose.words.gh.d(DocxDocumentWriterBase.java:733)
at com.aspose.words.gh.visitParagraphStart(DocxDocumentWriterBase.java:171)
at com.aspose.words.Paragraph.a(Paragraph.java:307)
at com.aspose.words.CompositeNode.acceptCore(CompositeNode.java:633)
at com.aspose.words.Paragraph.accept(Paragraph.java:302)
at com.aspose.words.CompositeNode.acceptChildren(CompositeNode.java:669)
at com.aspose.words.CompositeNode.acceptCore(CompositeNode.java:640)
at com.aspose.words.Cell.accept(Cell.java:167)
at com.aspose.words.CompositeNode.acceptChildren(CompositeNode.java:669)
at com.aspose.words.CompositeNode.acceptCore(CompositeNode.java:640)
at com.aspose.words.Row.accept(Row.java:161)
at com.aspose.words.CompositeNode.acceptChildren(CompositeNode.java:669)
at com.aspose.words.CompositeNode.acceptCore(CompositeNode.java:640)
at com.aspose.words.Table.accept(Table.java:101)
at com.aspose.words.CompositeNode.acceptChildren(CompositeNode.java:669)
at com.aspose.words.CompositeNode.acceptCore(CompositeNode.java:640)
at com.aspose.words.Body.accept(Body.java:57)
The memory was exhausted on Java heap space. : requested 8189976 bytes
Java heap size / max Java heap size = 69671648 / 88080384
Java perm size / max Java perm size = 14212312 / 88080384
******************************************************************************************

Sizes of 2 CSV files are 20,857bytes and 79,816bytes.
Each CSV file's data are inserted into each Word documents successfully.
But 2 word documents can't be combined.

Have you faced with this problem and have any suggestions?

I attached the source files.

CAZZ001BJ.java mailmerge

CAZZ002BJ.java combine document

PLS help us. Thanks.

Hi
Yuji,


Thanks for your inquiry. Most likely ‘OutOfMemoryError’ occurs when the system is running out of memory (less amount of space in RAM is available for Aspose.Words process to continue). I would suggest you please upgrade to the latest version of Aspose.Words i.e. v11.1.0 and let us know how it goes on your side. If you still face problem, please share some more detail about your issue and also share input template Word documents here for investigation purposes.

Best Regards,

Hi Awais,

Thank you for your reply.

We updated the product to 10.8.0 to 11.1.0 and tried the same test but the result was the same as before. However we found the way to solve the problem. We added -Xms512m -Xmx512m options to the command line of execute the java program and the error messages disappeared.

Anyway thank you for giving us the hints to solve it.

Regards,

Yuji Yamamoto

Hi,

We've solved the problem but the program process needs long time to combine docments. It needs 10 minutes to combine 15documents. If you have some hints to make the time shorter, please let us know. (pls check out the program CAZZ002BJ.java)

Thank you,

Yuji Yamamoto

Hi Yuji,

Thanks for your inquiry.

My colleague Awais has already stated the reasons. Moreover, please note that to calculate the number of pages of a document requires building the page layout in memory. With very large documents this of course takes a while and may even pose the risk of the application running out of memory in the process. It would be great if you share any sample documents here along with environment details. So that we can reproduce it on our side.