Hi Team,
we are using Aspose.Word.dll 10.3.0.0 license for generating word document.
we are merging more than 100 documents of size 600kb each and we are getting “OutOfMemoryException” error(please find the attachment for error ) when running the below code.
public void Merge(Document templateDocument, FileInfo[] filesToMerge, string Outputpath)
{
try
{
templateDocument.RemoveAllChildren();
// Loop thru each of the Word documents
foreach (FileInfo file in filesToMerge)
{
Document srcDoc = new Document(file.FullName);
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
DocumentBuilder builder = new DocumentBuilder(srcDoc);
templateDocument.AppendDocument(srcDoc,ImportFormatMode.UseDestinationStyles);
}
}
catch (Exception ex)
{
// Program.LogException(ex);
}
}
please see into this issue and proveid the solution for same.
Thnaks,
Samanvay
Hi Imran,
Thnaks for reply, actually we are generating a single document by merging multiple document at that time we are getting this error. below is the code which we are using.
private void button2_Click(object sender, EventArgs e)
{
string FolderPath = @“E:\Projects\DocList”;
DirectoryInfo Redir = new DirectoryInfo(@"" + FolderPath);
FileInfo[] AllDotm = Redir.GetFiles("*.docx");
string templatefilename = @“E:\Projects\DocumentTemplate\BlankWordDocument.docx”;
string Outputfilename = @“E:\Projects\DocumentTemplate\MergeDoc.docx”;
Document templateDocument = new Document(templatefilename);
templateDocument.RemoveAllChildren();
foreach (FileInfo file in AllDotm)
{
Document srcDoc = new Document(file.FullName);
templateDocument.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);
}
templateDocument.UpdateFields();
templateDocument.Save(Outputfilename);
MessageBox.Show(“Document generated Successfully”);
}
Thanks,
Samanvay
Hi Samanvay,
Please use the latest version of Aspose.Words for .NET 10.8.0 and let us know, If you still face exception.
As you suggested , we are used Aspose.wrod 10.8.0 version.
we are not getting "out of memory exception". but when we merge 100 documents. Memory usage and CPU usage increase till 90%. it effect other process and system get slow down.
Please provide solution for memory and CPU usage
Hi
Samanvay,
Thanks for reply,
If document taking memory we are fine with this.
We run same code with Aspose.Word.dll 10.3.0.0 license to and Aspose.Word.dll 10.8.0.0 license copy.
When we use Aspose.Word.dll 10.3.0.0 license to merge document but we don't not see CPU usage 90% .
We believe Aspose.Word.dll 10.8.0.0 have CPU Usage problem.
Hi Samanvay,
DirectoryInfo(@""
- FolderPath);
file in AllDotm)