We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ASPOSE Word Out Of Memory Error

We are doing a large mail merge; a 10,000 page report. The report takes 8GB of memory to run and it produces a 50MB file. How do we lower the memory usage of the report? Our web server only has 4GB of memory.

Here is the code. The “Execute” line highlighted in yellow takes up 4GB of memory and the “Save” line also takes up 4GB of memory.

<!–[if gte mso 9]>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";}


public void SaveBuilder(string inputPath, string outputPath, List list)

var license = new License();

var doc = new Document(inputPath);

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveEmptyParagraphs;

var dataTable = list.ToDataTable();
catch (Exception exception)

using (var fileStream = new FileStream(outputPath, FileMode.Create))
doc.Save(fileStream, SaveFormat.Pdf);
catch (Exception exception)

Hi Greg,

Thanks for your inquiry. Provided the limited RAM, the document you are trying to convert to PDF is simply too large. Please note that when you render a document Aspose.Words needs to build two model in the memory – one for document and the other for rendered document. That is why Aspose.Words utilizes more memory when you render a document than when you simply save a document in flow formats.
You should also note that usually Aspose.Words needs few times more memory than document size to build model of the document in memory. For example if your document’s size is 1 MB, Aspose.Words needs 10-20 MB of RAM to build its DOM in memory. Multiplier depends on format because some formats are more compact than others. For example DOCX format is more compact than DOC and RTF, and DOC is more compact than RTF.

So I am not sure the issue you reported can be resolved in Aspose.Words. I would advise you to use few small documents instead of one huge document.

Best Regards,


Thanks so much for your reply. Would the 10,000 page report fit into the 4GB of memory if we switched from ASPOSE Word to ASPOSE PDF and built the document programatically instead of doing the mail merge? In other words, add the paragraphs, images, and formatting manually.

Hi Greg,

Thanks for your inquiry and sorry for the delayed response. I feel your question is related to Aspose.Pdf, I will move your request in Aspose.Pdf forum. My colleagues from Aspose.Pdf component team will answer you shortly.

Best Regards,

Hi Greg,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for using our product.

Well, it depends on the contents of your PDF file. Creating a document with 10,000 pages will utilize a big chuck of memory but again, it will depend on the contents of your PDF file. Another suggested way in this regard is to create multiple PDF files and then merge them for better performance. You may download and try the latest version of Aspose.Pdf for .NET v7.4and in case you face any issue or need any further assistance, please feel free to contact support.

Sorry for the inconvenience,