Out Of memory Error When Creating PDF from Images

Hi,
I am trying to creating PDF from Images. But after 3 or 4 images it give me exception that out of memory.
Exact error is.
The CLR has been unable to transition from COM context

Following is code that i am using

foreach (FilePages filepage in fileObject.FilePages)
{
Aspose.Pdf.Page page = FilepdfDocument.Pages.Add();
MemoryStream mystream = new System.IO.MemoryStream(filepage.Data);
Aspose.Pdf.Image Pageimage = new Aspose.Pdf.Image();
Bitmap bitmap = new Bitmap(mystream);
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Right = 0;
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Width = bitmap.Width;
page.PageInfo.Height = bitmap.Height;
Pageimage.ImageStream = mystream;
if (bitmap.Width > page.PageInfo.Height)
{
page.PageInfo.IsLandscape = true;
}
else
{
page.PageInfo.IsLandscape = false;
}
Pageimage.FixWidth = page.PageInfo.Width;
Pageimage.FixHeight = page.PageInfo.Height;
page.Paragraphs.Add(Pageimage);
Pageimage.ImageStream = mystream;
}
FilepdfDocument.Save(PDFMstream);
}

@kshahzad

Thanks for contacting support.

Would you please explain a bit more like if you are facing the issue with every image file or some specific ones. Also make sure to use latest version i.e. Aspose.PDF for .NET 18.9 and in case it does not help, please share your sample image files in ZIP package. We will test the scenario in our environment and address it accordingly.