MemoryStream usage leads to out of memory exception
问题 I'am facing issues when using MemoryStream multiple times. Example: For Each XImage As XImage In pdfDocument.Pages(pageCount).Resources.Images Dim imageStream As New MemoryStream() XImage.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg) ' some further processing imageStream.Close() imageStream.Dispose() Next This piece of code cycles through images on a page of PDF file. The file may have up to cca 500 pages, lets say 5 images on each page. It leads to thousands of iterations. The