Hello there,
I am simply testing my application report generation using Aspose for any performance issue and getting System.OutOfMemoryException when calling Document.Save() after mail merge.
Here is the scenario:
Below is the code that’s calling MailMerge.Execute
PropertyTestMailMergeDataSource mmDataSource = new PropertyTestMailMergeDataSource(propertyList);
objTemplateDocument.MailMerge.Execute(mmDataSource);
foreach (Property objProperty in propertyList)
{
VendorsDataSource mmDataSource2 = new VendorsDataSource(objProperty.PropertyVendors);
objTemplateDocument.MailMerge.Execute(mmDataSource2);
}
foreach (Property objProperty in propertyList)
{
BuyersDataSource mmDataSource1 = new BuyersDataSource(objProperty.PropertyBuyers);
objTemplateDocument.MailMerge.Execute(mmDataSource1);
}
First issue: However, for second set of child objects (code in red color), it just takes too long to execute.
Please note that it’s happening only in case of my last MailMerge.Execute call. So, if I move the PropertyBuyers code up and PropertyVendors code down, it will happend for PropertyVendors.
Second issue: And after this code when I call document.Save(fileName), it throws error:
System.OutOfMemoryException
Stack Trace:
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
at System.IO.StreamWriter.Write(String value)
at System.Xml.XmlTextWriter.WriteStartElement(String prefix, String localName, String ns)
at System.Xml.XmlWriter.WriteStartElement(String localName)…
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.Ս(DocumentVisitor Վ)
at Aspose.Words.Body.Accept(DocumentVisitor visitor) …
at Aspose.Words.Document.ԅ(Stream Ӿ, String Ӽ, SaveFormat Ԇ)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at Aspose.Words.Document.Save(String fileName)
Please guide.
Thank you!