Document.Print() memory used not being released (Aspose.Words 16.1.0)

Hi,


I’m having issues with the memory release when printing a document in Aspose.Words 16.1.0 (latestrelease, 08 Feb 2016). When the document has finished printing the memory is not released.

We’re using Aspose.Words to print some rather large word documents over .Net.

I already looked in this forum (and Googled it too) and didn’t find a solution. Is there any way that the “Document” class can be disposed or closed (i.e. doc.Close() or doc.Dispose(); or equivalent)?

I put the following code (print document to default printer) behind a button on a simple Windows Forms application:

var doc = new Aspose.Words.Document(@“c:\temp\TestDocument.docx”);
doc.Print();

When the button is clicked the memory used jumps from ~10mb to 150mb+ for a document with less than 50 pages, and even more for larger documents, which is concerning. What’s even more concerning is that the memory does not get released once the printing has finished.

What I am expecting is that the memory used falls back down to ~10mb. How is this achieved?

See attached for an example (not an exact replica, but demonstrates a big rise in memory usage and then it not being released). Running in Windows 7 64 bit.

Thanks,

Hi there,


Thanks for your inquiry. We have tested the scenario and have not found any issue with Document.Print method. Please note that the memory may not be released until you close the application. You may call GC.Collect method after printing the document. Note that Aspose.Words has some internal static objects which remain live after GC.Collect because these static fields are GC roots.

Please let us know if you have any more queries.