Memory leak upon .MHT conversion


we suppose that a memory leak takes place when converting .MHT files using Aspose.Email .NET.
Please, find attached a simple app that you can use to reproduce the problem. To get a better view, I’d recommend to debug it using VS Profiler tool. Please, add a reference to Aspose.Email dll which I removed due to file size restrictions.

Thank (380.0 KB)


Thank you for contacting support.

We have noticed that you are working with Aspose.HTML for .NET API in shared application. Moreover, the MHT file is being converted to PDF 100 times whereas single iteration consumes about 110MB of memory, so huge memory consumption is expected for hundred conversions. Would you please elaborate your concerns a little more, while mentioning memory consumption values and screenshots so that we may investigate further to help you out.

Hi, @Farhan.Raza,
thanks for the quick reply!

Could you please specify what do you mean exactly by “shared application” ?

I’m calling conversions in a consequent manner, one after another, each conversion cycle has dedicated initialization and disposal of the required Aspose API objects (the “using” sections in the ConvertMht() method), so I expect that these resources are disposed of properly after each conversion. Instead I observe that the memory is piled up and not released by Aspose.Html. If you run the app using VS menu Debug -> Performance Profiler, and make a couple of screenshots, you may observe the objects held, e.g.

image.png (6.7 KB)

And after all 100 conversions have completed and a Garbage Collection is forced for several times, the memory held is still above 1 GB.

Our app uses Aspose to convert thousands of thousands of files literally, so performance and memory usage/allocation means a lot to us.

Please, let me know if we miss here anything important, but I can tell you that I’ve run dozens of similar tests for other file formats and it’s only the MHT that breaks that wild.


Thank you for elaborating it further.

We were referring to your sample application by mentioning shared application. Moreover, we have logged a ticket with ID HTMLNET-1671 in our issue management system for further investigations. We will let you know as soon as some significant updates will be available.

We see that problem was fixed in Aspose.HTML 19.1 and above. Can you please, confirm?


Thank you for getting back to us.

It has been resolved in Aspose.HTML for .NET 19.1 so please upgrade to latest version of the API and feel free to let us know if you face any problem.