How to release memory when the parameter dialog appears in Crystal Reports 2008

tharstern used Ask the Experts™
We are using Crystal Reports 2008 SP5 in VS2008.

One of our users found that after running a lot of reports (50+) that the memory of our application had increased considerably.

To track the issue I created a simple app that displays a report from a path.  There is no database connection in the report.

Running the report once loads all the dll's into memory.
If the report doesn't include a parameter then after running the report a second time the memory returns to what is was.

Change the report to now include a parameter and running the app again.
The parameter select dialog will now appear each time the report is run.
Running the report once loads all the dll's into memory.
After running the report a second time all the memory isn't released. It increased by about 2,000KB

If we keep running the report that displays the parameter dialog the memory keeps increasing and is never released.

We use the ReportDocument.Close() and ReportDocument.Dispose() and GC.Collect(), which does release the memory if there are no parameters.

I also tried running the report directly within Crystal Reports 2008 with the same results.

Is there something else needed to be done to dispose of the memory when parameters are displayed?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Freelance programmer / Consultant
Sounds like a bug in Crystal reports - have you checked with their website re a bugfix/patch ?

I doubt there is anything you can do ( apart from forcing crystal reports to restart = restarting your app? )
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013
Whenever I build an application to run reports, I include  forms for parameter promting so I don't have to rely on the Crtsal form which, in my opinion, isn't very user-friendly.  Also it can be somewhat limited in its capabilities.

I haven't heard of this as an issue but perhaps most people run a few reports then terminate the application.

I agree there is proably little you can do if you want to continue using the default parameter prompt screen.  Are you using a viewer?  Perhaps if you set it nothing or close the form it is on between rnning reports.

I've checked their website and can't find any fixes related to this.  I think SP5 is the latest version of CR2008.  Closing the application would fix the memory problem but it's not very practical for our application.

Writing our own interface would solve this but I was hoping to carry on using the standard prompt.

We're using the CrystalViewer on a form.  We set the CrystalViewer.ReportSource = ReportDocument of the loaded report. The form is closed after each report and we set CrystalViewer.Dispose and CrystalViewer = null when the form is closed.
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Top Expert 2011

Try to add
after GC.Collect() to see if this will change something
I added in the GC.WaitForPendingFinalizers() but unfortunately there is no difference.
I can create the issue within Crystal Reports 2008 SP5.
Create a report with no database connection and 1 parameter.  Keep refreshing the report and choose "Prompt for new Parameter Values" and the memory keeps increasing and is never released until I close the application.
Does this happen with anybody else?

Using PerfMon and monitoring the Private Bytes.
In Crystal Reports 2008 SP5, after opening the report the Private Bytes were 41,000,000.  After refreshing the report 10 times it went up to 65,000,000.  After 10 minutes waiting they were still at 65,000,000
I tried the same thing in Crystal Reports XI Release 2 and the memory doesn't increase after refreshing, it stays at around 41,000,000.
Does anybody know if the same thing happens in Crystal Reports 2011?  If not then we may have to upgrade.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial