We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Memorystream is not released after GC.Collect()

I am using  Syncfusion.Pdf.Net.Core(Version:21.1.41) to generate PDF from MemoryStream.

But memory is not released after I tried with different way.

Here is the logic, any idea how to release the memory after the process?

            // Save the PDF document to stream
            var stream = new MemoryStream();
            doc.Save(stream);

            // If the position is not set to '0' then the PDF will be empty.
            stream.Position = 0;

            // Close the document.
            doc.Close(true);

            stream.Close();
            stream.Dispose();
            stream.SetLength(0);
            stream.Capacity = 0;

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

1 Reply

IJ Irfana Jaffer Sadhik Syncfusion Team April 20, 2023 12:08 PM UTC

After examining the reported issue with the Visual Studio diagnostic tool, we observed that the memory did not decrease even after calling the GC collect. Upon further investigation, we discovered that the memory profiler is not compatible with the ASP.NET platform within Visual Studio. For more information, please consult the following link.

https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/profiling/profiling-tools?view=vs-2015&redirectedfrom=MSDN#BKMK_Diagnostic_events_dropped



Loader.
Live Chat Icon For mobile
Up arrow icon