Poor performance when update toc

it tasks minitus and huge memory when i updating the following word document.
Untitled_20170728_094148.zip (2.2 MB)

I tried to find and update the toc only, but it seems has no any improvement。
I tried to use following code to avoid the huge memory usage, but it did not update toc event if i set UpdateFields to true.
var folder = “D:\tempFiles”;
using (var stream = new MemoryStream())
{
var saveOption = SaveOptions.CreateSaveOptions(format);
saveOption.MemoryOptimization = true;
saveOption.TempFolder = folder;
saveOption.UpdateFields = true;
saveOption.UpdateSdtContent = true;
document.Save(stream, saveOption);
return stream.ToArray();
}

Is there any way to saving memory usage when update toc?

@qingyuan.ni,

Thanks for your inquiry. Please note that performance and memory usage all depend on complexity and size of the documents you are generating. If you’re loading huge Word documents into Aspose.Words’ DOM and performing some operations e.g. updating fields, more memory and time would be required.

Aspose.Words mimics the same behavior as MS Word does. If you update the TOC field using MS Word, you will get the same behavior.

@tahir.manzoor

I fully update the toc of the same document in ms word, it also costs minitus but the memory usage is much more lower than aspose. from opening the document to updating entire toc complete, the maximum memory usage of ms word is less then 400 MB, and which cost around 4 GB in aspose.
I think you may test my document under these tow conditions.

in addition, i think the following code SHOULD update toc, but it’s not, is it designed or a bug?

saveOption.UpdateFields = true;
saveOption.UpdateSdtContent = true;
document.Save(stream, saveOption);

@qingyuan.ni,

Thanks for your inquiry.

We have logged this issue as WORDSNET-15728 in our issue tracking system. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

If you want to update TOC field, you need to call Field.Update or Document.UpdateFields.

Please note that Aspose.Words mimics the same behavior as MS Word does. When a document is converted to fixed file foramt e.g. PDF, XPS, some fields e.g. NoteRef, NumPages, Page, PrintDate are updated without being update manually. The is the default behavior of MS Word. We added SaveOptions.UpdateFields property to control this behavior.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan