PDF To Image Out of memory

We are getting out of memory exception when trying to convert the attached image to PDF. The first time the image gets converted correctly, the second one we get the out of memory. What else do i need to dispose?


using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document())
{
foreach (var sourceFilePath in sourceFilesPath)
{
if(string.Compare(Path.GetExtension(sourceFilePath),".db",true)==0)
{
continue;
}
// Set margins so image will fit, etc.
Page page = doc.Pages.Add();
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Right = 0;
page.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;
page.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;
// Create an image object
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
// Add the image into paragraphs collection of the section
page.Paragraphs.Add(image);
// Set the image file stream
image.File = sourceFilePath;
}
//output
doc.Save(destinationFilePath);
}

Hi Luis,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 10.7.0 and I am unable to notice any issue. As per my observations, Image file is properly being converted to PDF format. For your reference, I have also attached the resultant file generated over my end.

Can you please try using the latest release and in case the issue still persists, please share some details regarding your working environment.

I am already using the latest version, my environment is windows 8. Please try to:


  1. Add the attached image to a PDF using the code more than 20 times and you will get the out of memory error.
  2. Add the image once, check the memory usage of the application and you would see that the memory is not release after the process is complete.
If you are doing the same with a different code, please share the code as i can replicate the issue every time.

luis.trujillo:
I am already using the latest version, my environment is windows 8. Please try to:

  1. Add the attached image to a PDF using the code more than 20 times and you will get the out of memory error.
Hi Luis,
Thanks for sharing the details.

I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWNET-39318 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.<o:p></o:p>

luis.trujillo:
  1. Add the image once, check the memory usage of the application and you would see that the memory is not release after the process is complete.
Hi Luis,
Thanks for sharing the details.

I
have also managed to reproduce same problem. For the sake
of correction, I have separately logged this problem as PDFNEWNET-39319 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.<o:p></o:p>

The issues you have found earlier (filed as PDFNET-39319) have been fixed in Aspose.PDF for .NET 18.3. This message was posted using BugNotificationTool from Downloads module by asad.ali

The issues you have found earlier (filed as PDFNET-39318) have been fixed in Aspose.PDF for .NET 19.10.