Out of memory exception while generating word document

Hi,
We are using Aspose 9.5 version. While generating a word document of size around 4MB and having around 380 pages, ‘Out of memory exception’ is thrown in production server. Could you please help regarding this issue?
Thanks,
Sowjanya

Hi
Thanks for your inquiry. It seems this problem does not occur with the latest version of Aspose.Words 10.7.0. Could you please try using the latest version and let me know how it goes on your side?
The latest version you can download here:
https://releases.aspose.com/words/net
Best regards,

Hi,
Thanks for the response. We evaluated the latest version of Aspose 10.7 with our application for generating the same word document in terms of memory consumption by profiling. We observed that UpdateFields and UpdatePageLayout methods are consuming more memory with Aspose 10.7 version when compared to Aspose 9.5 version. Please find the attached screenshots of memory profiler and sample word document.
Thanks,
Sowjanya

Hello
Thank you for additional information. Currently, during UpdateFields we automatically call UpdatePageLayout, so you do not need to call this method separately. It seems it is the reason of memory consuming.
Best regards,

Hi
Thanks for the quick response. We observed that memory consumption is less if we don’t call UpdatePageLayout seperately. But we noticed that Table of Contents are pointing to the right topic having page number which is different from Table of Contents page number. One more thing we observed that total no.of pages generated for the same word document using Aspose 9.5 version is different from Aspose 10.7 version.
Could you please help us regarding this?
Thanks,
Sowjanya

Hi
Thanks for your request. Could you please show me your code and attach your input and output documents here for testing. I will check the problem on my side and provide you more information.
Best regards,

Hi,

I have attached my code, input and output documents. I noticed the problem only for few places. For example i noticed this at 36th chapter 1st section in the output document which i have attached here. Please help me regarding this.

Thanks,
Sowjanya

Hello
Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words 10.7.0. Could you please try using the latest version and let me know how it goes on your side?

// Create document.
Document doc = new Document(@"C:\Temp\Document.doc");
doc.UpdateFields();
// Save output docuemnt.
doc.Save(@"C:\Temp\out.doc");

The latest version you can download here:
https://releases.aspose.com/words/net
Best regards,

Hi,

Thanks for the response. I used the latest version Aspose 10.7 to build the word document. I am able to reproduce when no.of pages are more but not all the times. It works fine when i open an existing word document and update the fields as given in your reply before. Can you please let me know regarding this?

Thanks,
Sowjanya

Hello
Thank you for additional information. Could you please provide me the template which you use for generate the document, those will allow me to reproduce the problem on my side using your code.
Best regards,

Hi,
I have attached the code, input documents which used to generate the word document in my previous reply. I have attached the output document too in that reply.
Thanks,
Sowjanya

Hello
Thank you for additional information. I see just output document (Document.doc) and data (Content.xml), but I also need your template (doc_template.doc) to reproduce the problem on my side.
Best regards,

Hi,
Please find the attached template used for generating word document.
Thanks,
Sowjanya

Hello
Thank you for additional information. But I still cannot reproduce the problem on my side, using the latest version of Aspose.Words 10.7.0 and the following code:

CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
mXmlReader = new XmlTextReader("C:\\Temp\\Content.xml");
// Build document from xml file
mdoc = doDocumentCreation();
mdoc.UpdateFields();
// mdoc.UpdatePageLayout();
mdoc.Save("C:\\Temp\\out.doc");
Thread.CurrentThread.CurrentCulture = currentCulture;

You do not need to call UpdatePageLayout after UpdateFields.
I have sent the document produced on my side to your e-mail.
Best regards,