Addressing Memory Usage and Disposal of Aspose.Words Document Objects

We are currently leveraging Aspose.Words in our service to convert DOCX files to HTML. we have encountered significant memory usage issues, especially when dealing with larger documents.

When converting a document of 2.5MB (resulting in an 83MB document.xml), Aspose.Words allocates approximately 3GB of memory. This has caused our service to frequently run out of memory, particularly when handling multiple simultaneous requests. Additionally, when requests time out and an OperationCanceledException is thrown, we face out-of-memory errors more often.

Our Questions:

  1. Is there a way to explicitly dispose of Document objects? We have not found a Dispose method available on the Aspose.Words.Document class.
  2. What are the best practices for managing memory when using Aspose.Words for high-load services?

@DivyaReddy Could you please attach your problematic document here for testing? We will check the issue on our side and provide you more information.

Aspose.Words always allocates more memory that actual document size. This is expected. Please see our documentation for more information:
https://docs.aspose.com/words/net/memory-requirements/
For reducing memory usage upon processing extremally large documents, you can try using LoadOptions.TempFolder, SaveOptions.TempFolder and SaveOptions.MemoryOptimization properties.