At Aspose.PDF v18.11.0 you introduced a memory leak when converting HTML to PDF. Allocated RAM is not garbage collected and child threads remain for all subsequent calls which quickly gobbles up system RAM. The below simplest implementation demonstrates the issue. Please fix it.
using System;
using System.IO;
using System.Text;
using Aspose.Pdf;
namespace AsposeHtmlToPdfMemoryLeak
{
class Program
{
static void Main(string[] args)
{
var outPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Path.DirectorySeparatorChar + "AsposePdf" + Path.DirectorySeparatorChar;
var html = "<h1>Header</h1>";
var makePdf = new MakePdfDocument();
Console.WriteLine("Press Enter to begin.");
Console.ReadLine();
for (int i = 0; i < 250; i++)
{
makePdf.Create(i, html, outPath);
}
Console.WriteLine("Press Enter to terminate.");
Console.ReadLine();
}
}
class MakePdfDocument
{
public void Create(int counter, string html, string outPath)
{
var outFile = outPath + counter.ToString() + ".pdf";
using (var memStream = new MemoryStream(Encoding.UTF8.GetBytes(html)))
using (var pdf = new Document(memStream, new HtmlLoadOptions()))
{
pdf.Save(outFile);
}
Console.WriteLine(outFile);
}
}
}