Starting with Aspose.PDF v23.11.0, there is a memory leak when constructing and disposing of Document objects. Performing simple Document constructor calls in a using block does not release the memory upon garbage collection:
var pdfPaths = Directory.GetFiles(assemblyDir, "*.pdf");
foreach (string pdfPath in pdfPaths)
{
// Using block will call .Dispose()
using (var document = new Document(pdfPath))
{
string version = document.Version;
Console.WriteLine($"Loaded Aspose Document [{Path.GetFileName(pdfPath)}]; version [{version}]");
}
}
This same code, when run with Aspose.PDF v23.10.0 and earlier does release (most of) the memory on garbage collection.
I’ve attached a proof-of-concept console application which demonstrates the issue including garbage collection calls and output of application memory bytes at each point in its process. A Results.txt file in the project shows the different results with various versions of Aspose.PDF: