Hi there,
Thanks for your inquiry. Please note that performance and memory usage all depend on complexity and size of the documents you are generating. While rendering a document to fixed page formats (e.g. PDF), Aspose.Words needs to build two model in the memory – one for document and the other for rendered document.
In terms of memory, Aspose.Words does not have any limitations. If you’re loading huge Word documents into Aspose.Words’ DOM, more memory would be required. This is because during processing, the document needs to be held wholly in memory. Usually, Aspose.Words needs 10 times more memory than the original document size to build a DOM in the memory.
We’re always working on improving performance; but, rendering will be always running slower than simple saving to flow formats (e.g. doc/docx).
truongminhlong:
My question is: Is there a way to release memory manually when ConvertTo finishes instead of GarbageCollector?
- 2nd issue: doc --> pdf tooks more than 1 hours and still not finishes
When the document is closed, all the DOM data is purged from memory during the next garbage collector cycle.
truongminhlong:
- 2nd issue: doc --> pdf tooks more than 1 hours and still not finishes
My question is: Does it has timeout option ?
Thread.Abort method is unsafe way for interrupt Aspose.Words execution. Aspose.Words has special interruption way using class InterruptionToken. Please use following code examples to achieve your requirement.
Hope this helps you. Please let us know if you have any more queries.
///
/// My Aspose document.
///
public class MyDocument : Aspose.Words.Document
{
public MyDocument(string fileName) : base(fileName) { }
public bool TryToSave(string fileName, int timeout)
{
InterruptionToken token = new InterruptionToken();
bool finished = SaveWithTimeout(token,
() =>
{
token.BindToCurrentThread();
try
{
Save(fileName);
}
catch (Exception ex)
{
Console.WriteLine("Interrupted");
}
}, timeout);
return finished;
}
private bool SaveWithTimeout(InterruptionToken token, ThreadStart threadStart, int timeout)
{
Thread workerThread = new Thread(threadStart);
workerThread.Start();
bool finished = workerThread.Join(timeout);
if (!finished)
{
token.Interrupt();
}
return finished;
}
}
MyDocument myDoc = new MyDocument(MyDir + "in.docx");
bool done = myDoc.TryToSave(MyDir + "Out.pdf", 1000);
Console.WriteLine(done? "Converted" : "Interrupted by timeout.");