CrystalReports ReportDocument memory leak with database connections

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.