SAP Knowledge Base Article - Public

1918401 - Is ‘GC.Collect()’ necessary even if ‘ReportClientDocument.Close()’ is used in RAS.NET SDK code?


Is ‘GC.Collect()’ necessary even if the below APIs are used in a Crystal Reports.NET SDK application?

  • ReportDocument.Close()
  • ReportDocument.Dispose()
  • ReportClientDocument.Close()


  • Crystal Reports 2008
  • Crystal Reports for Visual Studio 2010 (SAP Crystal Reports, developer version form Microsoft Visual Studio)
  • Crystal Reports Server 2008


  • Yes. It is a best practice and recommended. GC.Collect() could be used along with .Close and .Dispose methods or Crystal Reports .NET SDK and RAS.NET SDK.
  • When using the RAS API in conjunction with a RAS server, reports are stored on the Report Application Server, but they are represented on the Web server by an instance of ReportClientDocument.
  • If the ReportClientDocument instance passes out of scope without calling the ReportClientDocument.close method, the Report Application Server keeps the report open in memory, even though the report can no longer be accessed.
  • When those circumstances are repeated in a highly scaled situation, the memory on the Report Application Server fills with reports that are no longer being accessed on the Web server.
  • To resolve that problem, call the ReportClientDocument.Close method. The report is closed on the Report Application Server and the memory is released for further reports.
  • ReportClientDocument.Close method works at report object level and deals with only one object at a time.
  • GC.Collect() method is used to try to reclaim all memory that is inaccessible. It performs a blocking garbage collection of all generations.
  • All objects, regardless of how long they have been in memory, are considered for collection; however, objects that are referenced in managed code are not collected. Use this method to force the system to try to reclaim the maximum amount of available memory.
  • Both APIs free up the memory however, ReportClientDocument.Close is Crystal Reports specific API thus if there are any other .NET objects used in code such as ADO.NET objects, GC.collect() would be helpful.

See Also


bi, sap, beginner, business_intelligence_(businessobjects), sap_crystal_reports, visual, for, .net, crforvs, crvs2010, studio, sdk, crystal_reports,, cr, formula, crystal_reports_for_visual_studio_2010,, business_intelligence_(business, crystal_reports_2008, reportformula, reportformulatable, conditionformulas, crystal_report, code_resuability, crvs, cr2008, , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To


Crystal Reports 2008 V1 ; Crystal Reports Server 2008 V1