Free Support Forum - aspose.com

Image Conversion - Memory leak

Using Aspose.net PDF purchased this year, I made an winform program which converts PDF first page to PNG file.
However, it threw an outofmemory error every time.
I found that there is a memory leak as shown in the below picture.
image.png (32.0 KB)

Please check the memory leak.

static pdfAspo.Document _pdfDocument;
static PngDevice _pngDevice;
using (FileStream imageStream = new FileStream(transFileNameTall, FileMode.CreateNew))
{
Resolution resolution = new Resolution(350);

                    // Create PNG device with specified attributes (Width, Height, Resolution)
                    _pngDevice = new PngDevice(resolution);

                    // Convert a particular page and save the image to stream
                    _pngDevice.Process(_pdfDocument.Pages[1], imageStream);

                    _pdfDocument.Pages[1].Dispose();

                    _pdfDocument.Dispose();

                    // Close stream
                    imageStream.Close();
                }

@leekydo

Would you please share your sample PDF document with us as well. We will test the scenario in our environment and address it accordingly.

I converted the attached pdf file 50 times in a row.

Please refer to the result, and check the file.
image.png (32.9 KB)

Getting Started.pdf (1.9 MB)

@leekydo

We were able to notice that memory usage was not getting back to normal after completion of the loop of 50 iterations. Hence, we have logged an issue as PDFNET-49069 in our issue tracking system for the sake of correction. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.