Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005-2015 : Writing Code
Message Icon Topic: WinForms Memory Issue Post Reply Post New Topic
Author Message
JoeBacon
Newbie
Newbie
Avatar

Joined: 25 Jan 2007
Online Status: Offline
Posts: 4
Quote JoeBacon Replybullet Topic: WinForms Memory Issue
    Posted: 19 Mar 2007 at 3:21pm
I am working on a c# windows forms app in Visual Studio 2005 that dynamically generates reports that contain text and images.  There is a main report and several subreports that may or may not be displayed based on user preferences.  Each report is displayed on a form using the CrystalReportViewer control.
 
What I'm finding is that each time I display a report it uses enormous amounts of memory and when I unload the form it doesn't give the memory back.  After I've displayed several reports I finally will get an exception:
 
Exception:Could not load reportSystem.Exception: Load report failed. ---> System.Runtime.InteropServices.COMException (0x80041004): Not enough memory for operation.
 
Any suggestions on how to force crystal to give back all the memory would be greatly appreciated.
 
Joe B
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Mar 2007 at 4:01pm
I've had that happen when I haven't cleaned up objects well enough. I had to go back and thoroughly check that every report object is set to null afterwards.  However, CR has also had memory problems of its own.  Also try forcing garbage collection afterwards to make sure .NET cleans everything with the report objects. I would make sure you have the latest service packs as well. They fix bugs like this periodically.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
JoeBacon
Newbie
Newbie
Avatar

Joined: 25 Jan 2007
Online Status: Offline
Posts: 4
Quote JoeBacon Replybullet Posted: 20 Mar 2007 at 1:48pm
Thanks for that response. 
 
I am using the the Crystal Reprots that comes standard with Visual Studio 2005.  How would I tell if I have the latest fixes and if not how would I download any fixes I don't have?
 
 
Joe B
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 20 Mar 2007 at 2:16pm
go to the support site and click on the downloads link. Download the latest file and install it. I don't know the dates off the top of my head.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3678
Quote hilfy Replybullet Posted: 21 Mar 2007 at 10:45am

Also, if you're using the ReportDocument object model, be sure to .Dispose() the report document in the FormClosing event handler for the viewer page.  This will free up the memory faster.

-Dell
IP IP Logged
JoeBacon
Newbie
Newbie
Avatar

Joined: 25 Jan 2007
Online Status: Offline
Posts: 4
Quote JoeBacon Replybullet Posted: 21 Mar 2007 at 3:13pm
Thanks for that info Dell.
 
I am using the ReportDocument object model and tried the .Dispose() on the form closing and that seems to help but I still don't seem to be getting all the memory back.
 
I'm also creating DataSets using the SetDataSource() method to force the report to display the data that I want in the Main and sub reports.  I'm wondering if I need to do something get the report docuement to give up the references to the datasets.  It does seem that the amount of memory I lose on each report display is proportional to the size of the data in the dataset.  For example, one of my subreports may display several images, which causes me to "lose" a large amount of my memory.
 
 
Joe B
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3678
Quote hilfy Replybullet Posted: 22 Mar 2007 at 9:37am

I haven't done a lot of work with DataSets - just one module that gets run once a month, so I haven't' tried this...You might be able to .Clear() the DataSourceConnections property of the ReportDocument to help free up memory.

-Dell

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.047 seconds.