HIGH MEMORY Utilisation in using Aspose.PDF component while Conversion

Hi ,
We are using Aspose.pdf in our application to convert different file formats to Tiff.
We found that our application which is using Aspose.PDF component is utilizing most of the memory resources. We have used Aspose.pdf version 19.9

We are using object for converting different file formats to Tiff.
We observed that memory utilization on server is increasing and reaching 100%.
Then the application shows out of memory exception.

We found there were some issues while flattening the file. We have used flattenSettings , RenderingOptions in our code. Please find the sample source code attached.
PDFTest_SampleCode.zip (63.9 KB)

We have sufficient memory available on the server and previous version of Aspose.PDF.dll 9.3 was working fine.

Please review the code and let us know your suggestions on resolving the memory issue.

Thank You.

@52000537,

Thanks for contacting support.

I have checked sample project shared by you and unable to find any sample files. Can you please share source files to further investigate this issue in details. Before sharing requested files, can you please try to use Aspose.PDF latest version 20.3 on your end.

Thank You Adnan for looking into it .

This is a performance issue and we cannot reproduce it with sample files.
This is happening on our production.
Please check if there are any memory leak issues in the PDF objects
or anything in the code that you can observe.
We will try to use latest Aspose.PDF component but we may not be able to finalize on the issue since we cannot deploy the changes directly to production without testing.

Thank You.

@52000537,

I like to inform that version which you are using is lagacy version and now product has been improved a lot. Please try to use latest version you will see improvements and if there is still an issue than please share sample project so that we may investigate this issue in details.

@Adnan.Ahmad,

As I mentioned earlier this is happening on our Production Environment , we cannot replace existing component without any testing . So , I would like to ask you please have a look through sample code to see if you can observe anything related to memory leak issue.

I am mentioning details again to avoid any confusion.
We are using Aspose.pdf version 19.9 in our application. We observed that memory utilization on server is increasing and reaching 100%.
Then the application shows out of memory exception.

Can u please look into the sample project code PDFTest_SampleCode.zip (63.9 KB) to see if there is any memory leak issue in pdf objects. And since this is a performance issue , we cannot reproduce it with sample file. So I have not attached any sample file.

So , please have a look once on shared sample code and let us know if you observe anything.

Thank You.

Hello,

I am observing the memory leak using de PdfConverter object (using Aspose.PDF 20.3.0)
Code to reproduce is fairly straightforward:

using(var converter = new Aspose.Pdf.Facades.PdfConverter())
{
converter.Resolution = new Aspose.Pdf.Devices.Resolution(200);
converter.BindPdf(filename);
converter.DoConvert();
converter.Close();
}

Here is a sample Visual Studio 2019 project with a test file. The memory leak is easy to spot using the memory profiler.
AsposePDFMemoryLeak.zip (1.6 MB)

Thanks a lot for looking into it

@VincentBbb,

I have worked with sample project and unable to observe any memory leak issue. Can you please share screenshot so that I may further investigate this issue in more details. Also please share complete environment details as well.

Hello,
thanks for investigating

Here is a screenshot of visual studio memory profiler after execution of my sample project.
There are hundreds of pending objects from Aspose.PDF.dll.
MemoryProfilerAsposePDF.PNG (36.8 KB)

I’m using Windows 10 x64 Professionnal version : 18362.720
Intel Core i7, 16GB

The sample project uses .NET Framework v4.5.2

Hello,
I checked (again) my sample project and it turns out those pending objects are not adding up on a big batch.
Don’t know what those are, but they are not the leak I am looking for.

Sorry for bothering you !

Thank You @VincentBbb for looking into this.

@Adnan.Ahmad
Please let us know if you have any findings or suggestions on the issue ? We dont have any other code apart from what we sent in sample code. so there may be something in the code/Aspose PDF objects thats causing memory leak.

Thanks.

@52000537,

I like to inform that I have worked with source project shared by you using my own test file and whole process took 172 MB. I also like to inform that some issues are document specific as well as environment and deployment specific. I have used latest version of Aspose.PDF 20.4 on my end while you used Aspose.PDF 19.9 on your end. Can you please try to use latest version on your end.

We have the same issue.

  1. The file isn’t converted correctly. This is after multiple mails and support tickets and promises that it would be fixed in a later version. That has been over 6 months now and we still can’t properly convert files.
  2. We have a fairly, but not really extremely big PDF (which can be found here: download ) and that uses over 2GB over memory when converting. This is killing our processes and it is limiting our options to serve our own customers.

Please, take this seriously and fix this. We are considering taking our business elsewhere because we NEED this component to do our job. And right now it is failing us.

2021-03-19 Memory usage.png (216.7 KB)

@ibvdev

Have you tested the scenario with 21.3 version of the API? We ran a test in our environment while using Aspose.PDF for .NET 21.3 and converted your file into PNG images. We noticed that memory consumption was 20-25MB across the whole process of conversion. It seems like the memory consumption is quite improved in the latest release. We request you please test your scenario using it and let us know in case you still notice any issue.

We used the below code snippet for testing:

Document pdfDocument = new Document(dataDir + "FailingBigPdf.pdf");
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
 string tmpImgToInsert = DateTime.Now.Ticks + ".png";
 using (FileStream imageStream = new FileStream(dataDir + "pngs\\" + tmpImgToInsert, FileMode.Create))
 {
  var pngDevice = new PngDevice(new Resolution(300));
  pngDevice.Process(pdfDocument.Pages[pageCount], imageStream);
  imageStream.Close();
 }
}