Memory doesn't get freed after Print()

When I print a large PDF with hundreds of pages, the RAM will be filled like crazy. For a ~300 pages PDF I get like 20GB RAM usage.


The memory usage here for a smaller PDF file, but which still uses pretty much RAM:



Memory doesn't get freed completely after Printing and Unloading:

 


Simplified version of the code which I am using:

PdfDocumentView document = new();


document.Load(stream);

document.Print(etiketteSetting.SelectedPrinter);


// Unload the Syncfusion print component (or else memory leaks will occur)
// The acual unload will occur when the next document gets loaded.
// So the memory will stay on the same level as long as nothing is printed after a big print job.document.Unload(disposeDocument: true);


How can I disable this memory hogging? I don't want to print the same PDF a second time. A PDF gets only printed once in my app, so I don't need any caching or other stuff. I want everything to be disposed after the Print().


10 Replies

MB Manuel Bachmann June 30, 2021 11:51 AM UTC

I upload here a test with a 200 page PDF as well, to deliver real life results:

 



DD Divya Dhayalan Syncfusion Team July 1, 2021 02:21 PM UTC

Hi Manuel, 
Based on the details you have provided; we suspect that you are facing the issue that “Memory doesn't get freed after Printing the document” with the version < 19.2.0.44. We have recently fixed the memory issue in printing and included in our latest version 19.2.0.44. 

Our latest version of NuGet package has been published in the nuget.org and please find the link below: 

Please find the release notes bug fixes details of 19.2.0.44 in the link: https://help.syncfusion.com/wpf/release-notes/v19.2.0.44?type=all#pdfviewercontrol-bug-fixes   
So, we request you to try our latest version of PDF Viewer and let us know whether the issue is resolved.  

Regards, 
Divya 



MB Manuel Bachmann July 1, 2021 03:22 PM UTC

I already use version 19.2.0.44 of the NuGet package, so this issue is not yet resolved.


This is from my .csproj file:




SS Sathish Shankar Syncfusion Team July 2, 2021 05:56 PM UTC

Hi Manuel, 
 
We have tried to reproduce the reported issue with our documents, but the memory issue is not reproduced in the latest version. We could see that the memory is released after the print process ends. Also once the printing is completed, you can unload the document if you do not need to document to print again as you have mentioned . 
 
We suspect the issue occurs due to the document which you used. So, we have created the sample for your reference. You can download the sample from below link. 
 
If you still face the issue, we request you to please modify the sample and provide the document to reproduce the issue from our end. Also please share the printer details. This information will be helpful for us to analyze more and provide you a better solution 
 
With regards, 
Sathish Shankar 



MB Manuel Bachmann replied to Sathish Shankar July 5, 2021 09:14 AM UTC

 Hi Sathish,


Thank you for investigating. It is correct that your sample (and the one I posted in the first post) won't get this issue. I attached a stripped down version of my code with an extreme example (495 PDF pages) where you should see the issue I'm facing.

It has to do something with the configuration I think, but I can't spot what exactly triggers this memory behaviour.


My app is a .NET 5 WPF app, so you need VS 2019 to open it.


The crazy memory usage in the example I posted:



Attachment: PdfViewerWPFAppNet5_60c4358d.zip


SS Sathish Shankar Syncfusion Team July 6, 2021 04:58 PM UTC

Hi Manuel, 
 
Thanks for sharing the sample with us. 
 
We can reproduce the issue “Memory doesn't get freed after Print()”  in our end. We have forwarded this issue to our development team for further analysis, and we will update further details on 8th July 2021. 
 
With regards, 
Sathish Shankar 



SS Sathish Shankar Syncfusion Team July 14, 2021 04:32 PM UTC

Hi Manuel 
  
Sorry for the delay. 
   
We have analyzed further to release the memory in the given sample. We Could see the memory holds in the sample level and memory stream. We can release the memory which is holds in the sample level by using GC.Collect and GC.WaitForPendingAnalyzers . Here we have attached the code snipped for your reference.  
 
Code snippet :  
 
GC.Collect(); 
GC.WaitForPendingFinalizers(); 
 
 
However, the part of memory holds in the page’s memory stream. We confirm that the issue “Memory not released after printing when using stream” is a defect.  The patch for this fix is expected to be available on July 28th, 2021.   
  
Please find the feedback link below,    
  
Regards,  
Sathish Shankar 
 



SS Sathish Shankar Syncfusion Team July 28, 2021 07:12 PM UTC

Hi Manuel, 
 
Sorry for the inconvenience. 
 
The issue Memory not released after printing when using stream” has been fixed. Due to internal issues, we are unable to generate patch for this fix, so we have created custom assemblies for your reference. We will include the fix in our upcoming weekly NuGet release which is expected to be available on 3rd August 2021.  
 
Please download the custom assemblies from the below location:  
 
Please find the feedback link below,  
 
Regards, 
Sathish Shankar 



DD Divya Dhayalan Syncfusion Team August 3, 2021 07:25 PM UTC

Hi Manuel,  
   
As we mentioned earlier, we have included the fix for this issue “Memory not released after printing when using stream” in our latest weekly NuGet release, so kindly upgrade to latest version v19.2.0.51 to get the issue resolved.    
     
   
Disclaimer: This fix will be included in our 2021 Volume 2 SP1 release which will be available in August 2021  
   
Please find the feedback link below,  
   
Regards,  
Divya 



DD Divya Dhayalan Syncfusion Team August 13, 2021 04:30 PM UTC

Hi Manuel, 
  
As we mentioned earlier, we have included the fix “Memory not released after printing when using stream” into the 2021 Volume 2 SP-1 release.  
 
We are glad to announce that our Essential Studio 2021 Volume 2 SP release v19.2.0.55 is rolled out and is available for download under the following link.  
 
Please find the feedback link below, 
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
  
Regards, 
Divya  


Loader.
Up arrow icon