We are using Aspose to convert PDFs to PDF/A but the Convert-method in the latest version, 24.9, has a significant memory leak. The memory leak can be demonstrated with the code below. Debugg the test in a Microsoft Unit Test project and watch the amount of memory used by the process climb. Comment out the Convert line and the memory leak goes away.
using System.Net;
namespace TestAsposeConvert
{
[TestClass]
public class MemoryLeakTest
{
[TestMethod]
public void PdfConvertLeaksMemory()
{
var client = new WebClient();
using (var pdfStream = new MemoryStream(client.DownloadData("https://s3.us-west-2.amazonaws.com/aspose.files/Corporate/Brochures/d6b7973eea4d43529e53268f0c7864ea/All/Brochure_-_Aspose.3D_for_.NET.pdf")))
{
for (int i = 0; i < 10000; i++)
{
using (var pdf = new Aspose.Pdf.Document(pdfStream))
{
var conversionOptions = new Aspose.Pdf.PdfFormatConversionOptions(Aspose.Pdf.PdfFormat.PDF_A_2A) { };
// Comment out this line to avoid the memory leak:
pdf.Convert(conversionOptions);
}
}
}
}
}
}
Hi Asad.ali, gladly. Here is a screenshot showing it leaks around a half GB memory in 22 seconds due to repeated exceptions thrown in the Aspose.PDF code (“Ausnahme” is German for Exception): image.png (130,0 KB)
After running for under three minutes it leaks more than 4 GB. image.png (28,0 KB)
Here is a screenshot showing that without the line of code “pdf.Convert” it looks very different: image.png (131,5 KB)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-58244
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The ticket has just been logged in our issue tracking system and it is still pending for an initial investigation. We’re afraid that we cannot offer any workaround at the moment. However, we will look into the possibility and share as soon as we have some results.