CrystalReports ReportDocument memory leak with database connections

前端 未结 1 1204
一向
一向 2021-01-12 10:55

I\'ve spent the past few days looking into that and I can\'t seem to figure it out.

I have a c# WinForms application that uses the R

相关标签:
1条回答
  • 2021-01-12 11:13

    It's very tricky with Crystal Report to clean up the mess it creates with memory. (No offence to SAP)

    You will have to first close and dispose the ReportDocument

    rpt.Close();
    rpt.Dispose();
    

    And then assign nulls to the ReportViewer and dispose.

    CRViewer.ReportSource=null;
    CRViewer.Dispose();
    CRViewer=null;
    

    And finally, you have to do the two pass GC collect.

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

    Please note that it is generally not recommended to call GC.Collect() but sometimes when memory is too much of an issue and third party COM component's like crystal report has issue with getting disposed properly, we may have to go this route.

    0 讨论(0)
提交回复
热议问题