Memory not being released

We are using the .NET version of Aspose.Cells. The issue we are running into is that after reading in the contents of an excel sheet and then disposing of everything, the memory from the RecyclableMemoryStreamManager is not being released.

We are utilizing the CellsHelper.CustomImplementationFactory with this class:

public class AsposeMemoryStreamHandler : CustomImplementationFactory
    private RecyclableMemoryStreamManager manager = new RecyclableMemoryStreamManager();

    public override MemoryStream CreateMemoryStream()
        return manager.GetStream("AsposeMemoryStreamHandler");

    public override MemoryStream CreateMemoryStream(int capacity)
        return manager.GetStream("AsposeMemoryStreamHandler", capacity);

Do you have any insight into how we can alleviate these memory issues? Are there any implementation details of the CellsHelper.CustomImplementationFactory that we are missing that could be causing this?


Thanks for your query.

Please share your sample file and console application(runnable) with us for our testing. We will reproduce the problem and provide our feedback after analysis.


We would like to further update you that, to keep all original data of the template file which may be used later for re-saving the workbook, currently we keep the stream in memory together with the Workbook object in memory. So, during the life scope of the Workbook object, the memory stream cannot be released. If you disposed the Workbook object and all other things including the memory stream, then the memory should be released.

We will make optimization for the memory performance too, after that the original stream should be able to be released even if the Workbook object is live. However, it is bit complicated and it will take some time to implement such enhancement.


Currently testing this requires integration with a significant portion of our codebase. I appreciate the additional info though, we will do some more testing keeping those pointers in mind. If we are unable to resolve our issues I’ll spend some time producing a sample app to reproduce the problem.



Thank you for the acknowledgement and we will wait for your feedback after testing at your end.


Please try our latest version/fix: Aspose.Cells for .NET v18.11.7:

Aspose.Cells18.11.7 For .Net2_AuthenticodeSigned.Zip (4.7 MB)
Aspose.Cells18.11.7 For .Net4.0.Zip (4.7 MB)
Aspose.Cells18.11.7 For .NetStandard20.Zip (3.8 MB)

Your issue should be fixed in it.

We have improved the process of loading OOXML-format template files such as XLSX, XLSM etc. With the new fix, you should be able to get better memory performance, especially for loading large template files. Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-46439) have been fixed in Aspose.Cells for .NET v18.12. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

Initial tests with this version are quite promising. In my sample application I saw a reduction of memory usage from ~180MB to ~20MB while working with a large .xlsm file.


Good to know that you got better results using latest version. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.