Memory usage with ReportDocument and windows viewer 
Author Message
 Memory usage with ReportDocument and windows viewer

I am concerned that the memory is not being released after I'm done
previewing a Crystal Report in a windows forms application.  After opening
up a number of reports I get a System.OutOfMemoryException thrown.  There is
only one DataSet which is not connected to any type of database, the tables
and rows are created earlier with the values found in a text file.  The
program does the following each time the user wishes to view a report (code
is below),

1.) Creates a ReportDocument
2.) Loads the ReportDocument with a report file (.rpt)
3.) Calls the SetDataSource() method with the DataSet
4.) Sets the ReportSource property of a CrystalReportViewer with the

The user can then look at the report for a time and can generate more
reports, each with its own CrystalReportViewer object.  When they are done
looking at the report (but do not wish to close the application yet), the
can click a Close menu item which,

5.) Calls the Close() method for the ReportDocument.
6.) Sets the ReportSource property of the CrystalReportViewer to null.

However, I don't think the Close() method is actually releasing the memory.
On Windows 2000, I'm using the Administrative Tools->Performance application
to look at the "Commited Bytes" and "Commit Limit" counters, which are
available in the "Memory" performance object.  If enough crystal reports are
created (steps 1-4), the "Commited Bytes" equals the "Commit Limit" and the
OutOfMemoryException is thrown.  However, step 5 does not make the "Commited
Bytes" counter decrease as I expect it would.

I've included some code snippets below in C#, I know this a VB focused
newsgroup but any help anyone could provide would be greatly appreciated.
I've searched the Crystal Decisions web site to no avail.

Thanks in advance,


// Crystal report viewer for windows forms
// (initialized by code created by Visual Studio)
private CrystalDecisions.Windows.Forms.CrystalReportViewer

// ------------------------------------------------
// --- InitializeReport(dataSet, reportFile) ---
// ------------------------------------------------
public void InitializeReport(string reportFile)
  DataSet dataSet = new DataSet();

  // Create tables and rows for the DataSet by hand using
  // i.e.  DataRow row = myTable.Rows.NewRow()
  //        myTable.Rows.Add(row);
  //        ...

  report = new ReportDocument();



// ----------------
// --- Close() ---
// ----------------
public void Close()
  ReportDocument reportDoc =
  if(reportDoc != null)

  crystalReportViewer.ReportSource = null;


Wed, 31 Aug 2005 05:33:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Crystal Viewer Does not accept ReportDocument as source

2. ADO Causes 100% Memory Usage/Increases in VM Usage

3. Process CPU Usage/Memory Usage

4. Outlook, custom forms, Active-X and Memory Usage?

5. Memory usage

6. Understanding Memory Usage

7. Object Memory Usage

8. How can i avoid 100% usage of memory while using loops

9. memory usage question VB6 vs .Net

10. Memory usage

11. Managing Memory Usage in VB.Net


Powered by phpBB® Forum Software