Guidelines on disposing Aspose.Words object

Hello,

We are running Aspose.Words in a sharepoint based solution. As a result it runs inside an Application pool that is recycled only once a day to clear up free resources.

The problem we are seeing is that during the conversion of large documents (600 pages, 14MB file size) the conversion process uses hundreds of megabytes. Now, this is not a problem by itself, but it appears that the memory is never reclaimed or freed up by the garbage collector. Subsequent conversions of the same document continue to eat up more and more memory.

Are there any guidelines on how to free up memory used by Aspose.Words?

We are using Aspose.Words 6.1.0.0 to convert documents to PDF.

Regards,

Jeroen

Hi
Thanks for your request. Could you please attach the document that causes the problem? I will investigate the issue and provide you more information.
Best regards.

We have performed further tests. Here are our observations.

  1. When using a regular MS-Word file containing just plain text then we are not observing any memory degradation.

  2. When we are creating an MS-Word file (and corresponding PDF) completely in code by just reading lines of plain text into it, then we are not observing any memory degradation.

  3. When we use a ‘real world’ MS-Word file with images, tables and everything else you can expect in a typical document (See attached) then memory is not released and the system becomes unresponsive after 60-70 requests due to excessive paging (See attached screenshot).

This is a very serious problem as we are not able to release our product to the market with serious memory leaks such as this one. We are keen to release our product, which is why we purchased the latest version of Aspose.Words last week.

I understand that the entire solution is written in .net native code, but - at the risk of stating the obvious - that doesn’t mean that the Garbage Collector magically releases ALL memory. There are many situations, such as circular references, where the GC cannot release memory even though objects are no longer used.

I appreciate Aspose’s support team is very responsive, but this time I would like to see an ETA for when I can expect a fix for this.

Regards,

Jeroe

As a final test we have modified our code to call the Garbage Collector explicilty after every conversion. Other than this being extremely bad practice, it just delays the inevitable and the system continues to leak memory.

If we use your document to convert 100 times we will see leak memory? Do you do DOC to PDF conversion using Document.SaveToPdf method?

Hello Roman,

Repeatedly loading the document and saving it as PDF should reproduce the problem.

We are using the native PDF Saving functionality introduced in Aspose.Words 6.0.0.0.

In summary:

doc = new Document(sourceStream, null, documentFormat, null);
MemoryStream pdfStream = new MemoryStream();
doc.Save(pdfStream, SaveFormat.Pdf);

Regards,

Jeroen

Hi
Thanks for your request. It seems to be that this problem is related to the existing issue #7179 in our defect database. We will further investigate the issue and provide you more information.
Best regards.

Hi.

We have done some further tests and commented out the one line in our code that does the PDF conversion, while keeping the rest exactly the same. When running this test for 10 minutes for a total of 1400 requests we are not seeing any obvious memory leaks.

The source of the problem appears to be in the PDF Conversion bit. I hope this issue is given a high priority.

Regards,

Jeroen

Hi
Thank you for additional information. Yes, this issue has high priority in our defect database. We will further investigate the issue and provide you more information.
Best regards.

Will fix in the next few days.

The issues you have found earlier (filed as 7179) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by alexey.noskov.

We cannot test this as it has introduced a new issue, see
https://forum.aspose.com/t/96453

I already answered in this thread.
Best regards.