We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Memory leak under .NET Framework

NOTE: issue found only in .NET Framework (4.8 in our case), not in .NET Core.

We run a high volume HTML to PDF conversion on Azure App Services. HTML frequently contains images. When we migrated from a different vendor to Aspose, we began to experience rapid increase in memory usage, leading to eventual slowdowns and even complete lack of response from the app service, until forced restarts. Analyzing memory dumps showed the the memory is tied in Large Object Heap, further investigation indicated that memory is being mostly used by image sizing functions of System.Drawing namespace, called by Aspose.
We worked around the issue in one of our environments by moving the conversion method to a .NET Core Azure function, where the issue doesn’t seem to appear. Unfortunately, in a different version of our product this is not an option.
We need you guys to investigate and fix the issue, as it prevents us from using your product fully. We prefer to use the same component in all our environments, as for now we are forced to still use one of your competitors’ components.


Would you kindly share some sample files, code snippet and screenshots of the memory hike from your environment? Also, please make sure to use 23.1 version of the API before sharing the requested files. We will further proceed to assist you accordingly.

Unfortunately, we don’t have any samples, as those are customers’ documents and we don’t store them. I would assume most have some sort of logo at the top. I can ask for an example if absolutely necessary. The images are part of the HTML in base64 format, like so (example):

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4
  //8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

We simply do this:

var ms = new MemoryStream();
var writer = new StreamWriter(ms);
ms.Position = 0;
var pdfDocument = new Document(ms, options);
return stream;

The issue arises when the conversion is done in high volumes (several each minute).
We run on Azure App service Premium V3 with 16GB RAM, so machine resources are not an issue.

And yes, we are using 23.1


Yes, we do need sample file with which you are observing the memory leak issue. It would help us in replicating the issue in our environment and address it accordingly.