PdfViewer in UserControl cant release Memory after UserControl is removed

I have a WPF window with a list of documents(DataGrid) (from an sql VarBinary(Max) field binding

on click of list item, I load the datafiled into a Memoystream like:

 public MemoryStream docStream = new() 

docStream  = new MemoryStream(dt.Rows[0].Field<byte[]>("Document"))

In the WPF MainWindow i have a ContentControl where I place via code a UserControl that only has  a PDFViewer, then I load the memorystream into the PdfViewer like this:

 ucPdfView.Instance.myPdfViewer.Load(docStream);
when a user clicks on other documents in list it wil reload the new sql datafiled into the Memorystream etc...
This all works well..
but while navigating and previewing documents, the memory usage keeps going up until I get an out of memory error.... even if you just keep clicking on same item in list over and over..
I cant find a way to release this memory

If I follow same steps as above but just omit the asising the DocStream to the pdfviewer (no pdf preview showm just the blank pdfviewer, but I do fill the MemoryStream docStream  ) i have no problems with memory usage...

Im not using MVVM in this app.... could you provide a sample of an optimized way to achive this correctly?



3 Replies

RB Rajavignesh BalaSankar Syncfusion Team March 7, 2022 12:50 PM UTC

Hi Eric,


For the same issue, we've received a ticket under your account. Please follow up on the ticket for further updates.


Regards,

Raja Vignesh.



LK Ludwig Kienberger replied to Rajavignesh BalaSankar March 11, 2023 12:04 AM UTC

Since I have exactly the same problem as described here in my work, I would also be very interested in a solution. You have referred to a private ticket in the last comment. I would be very interested to know how this issue has progressed, whether there is already a solution, or not yet. If I had to open a ticket myself, it would probably say the same thing as here, so I would be happy if I could save myself the trouble.



KG Krithika Ganesan Syncfusion Team March 13, 2023 03:04 PM UTC

Ludwig, the above-reported issue occurred with a specific PDF document. We have fixed that issue, and that fix is available in current versions. We suspect the issue you have been facing might be document-specific. So, please share the PDF that would help us reproduce the issue on our end. It would be helpful for us to further investigate this.


Loader.
Up arrow icon