Crystal Reports Viewer Memory Leak

  • Thread starter Thread starter ian_jacobsen
  • Start date Start date
I

ian_jacobsen

It's rare that you see someone simply posting a solution rather than
posing a question, but this one caused enough stress that I thought
everyone should would at least appreciate this as a reference
(considering that Crystal Reports has zero documentation).

We had a form that contained a CrystalReportViewer that would display
a report object that it was given. The viewer, the report object, and
the dataset that was used to create the report were all being
disposed. However each time that we ran a report, clicked through
each page of the report, and closed the form we would be left with a
substantial chunk of memory leaked into oblivion. The viewer seemed
to acquire memory at a remarkable rate of 5-10 MB per page, and never
give it back.

The solution after playing around for a while was to set the
CrystalReportViewer ReportSource to null before disposing the viewer.
I thought that viewer should have been responsible for cleaning up all
of its own junk, but apparently I was wrong.

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

--IAN
 
Back
Top