Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: Garbage Collection Post Reply Post New Topic
Author Message
Dave P
Newbie
Newbie


Joined: 29 May 2007
Online Status: Offline
Posts: 13
Quote Dave P Replybullet Topic: Garbage Collection
    Posted: 21 Aug 2007 at 8:21am
I recently had the following error message occur
 
"The maximum report processing job limit configured by your system administrator has been reached"
 
Apparently the error means that there is too much load on the reporting engine. In Crystal X onwards the reporting engine was optimized for greater report throughput, and a default print job limit of 75 was set in the registry. A solution to this problem is to either raise the limit in the registry, or call ReportDocument.Close & ReportDocument.Dispose in the Page_Unload event (the method I chose).
 
The problem is that in my report viewer page, when you click on a navigate button in the viewer to go to another report page, the unload fires which closes and disposes the local report object, but also the one stored in the session. So when the page tries to reload it can't find the report so exceptions. Below is my code:
 
private CrystalDecisions.CrystalReports.Engine.ReportDocument myReport;
 
private void Page_Load(object sender, System.EventArgs e)
{
   
   myReport = (CrystalDecisions.CrystalReports.Engine.ReportDocument)Session["myCrystalReport"];

      myCrystalReportViewer.ReportSource = myReport;
}
 
private void Page_Unload(object sender, System.EventArgs e)
{
       if(myReport != null)
       {
             myReport.Close();
             myReport.Dispose();
       }
 }
 
Any ideas as to how to get around this?
 
Thanks.


Edited by Dave P - 21 Aug 2007 at 8:23am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 21 Aug 2007 at 8:36am
I had a similar problem a while back, and I put the set the Session() object to null on the page that the user goes to after they are finished looking at the report. For example, if you have a reporting menu page, then when that page loads I would check to see if there are any report objects left over in the Session collection and dispose of them. This lets you keep the report objects active while viewing and kill them off once the user has finished.

Please report back how this goes for you. I only needed to do it one time a while back and I want to see how it works for you. Thanks.
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
Dave P
Newbie
Newbie


Joined: 29 May 2007
Online Status: Offline
Posts: 13
Quote Dave P Replybullet Posted: 23 Aug 2007 at 4:54am
Thanks for replying Brian.
 
I have been able to do as you said and kill off the session objects when no longer needed. However, I have come across something else. I understand that when the Crystal Report Viewer opens a report, it creates a temp .rpt file somewhere on the C drive. In my case it is in the following location:
 
C:\Documents and Settings\<<Computer Name>>\ASPNET\Local Settings\Temp
 
The problem is that this never seems to be cleaned up, and my folder had over 1500 temp .rpt files in it! Would calling Close and Dispose on the report document remove the temp reports from here?
 
I went down this avenue and got an idea from a post I'd seen about creating a factory class to keep track of all report objects created. My class is shown below:
 
public class ReportFactory
{
      public static Hashtable reportTable = new Hashtable();
     
      public static void CreateReport(string key, string path)
      {
            ReportDocument report = new ReportDocument();
            report.Load(path);
            reportTable.Add(key, report);
      }
  
      public static void CloseReport(string key)
      {
            ((ReportDocument)reportTable[key]).Close();
            ((ReportDocument)reportTable[key]).Dispose();
            reportTable.Remove(key);
      }
}
 
In theory I should have all the report objects in one place, and destroy them as and when needed using CloseReport. This doesn't seem to work as expected, and the files are sometimes removed from the temp folder, but sometimes not. I am slightly confused, so any light you could shed on the matter would be greatly appreciated.
 


Edited by Dave P - 23 Aug 2007 at 4:55am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 23 Aug 2007 at 11:54am
yeah, the tmp files are a problem. Unfortunately, I don't know how to handle them. I just manually clean them up when I come across them. With you having so many on the server, I would write a little program that runs in the background and deletes all tmp files that are two days old. That would keep the folder clean.

In fact, I think I'll go check my own server now....

Yep. 217 temp rpt files on my server. I have a question for you though. I see a lot of "~cpe{guid}.tmp" files as well. Do you know if this is from another application, or is CR creating ~cpe temp files as well? Do you have them also?
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
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 23 Aug 2007 at 11:55am
I'm going to follow up on this next time I talk to tech support at BOBJ. See what their thoughts are.
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
jayaaniithaa
Newbie
Newbie


Joined: 04 Dec 2006
Online Status: Offline
Posts: 5
Quote jayaaniithaa Replybullet Posted: 24 Nov 2008 at 12:54pm
I am getting "Load Report Failed" error when the .rpt files in temp folder is not cleaned, even after disposing the reports in Page_Unload event. 
Please let me know the solution if you have solved this issue.
IP IP Logged
jayaaniithaa
Newbie
Newbie


Joined: 04 Dec 2006
Online Status: Offline
Posts: 5
Quote jayaaniithaa Replybullet Posted: 24 Nov 2008 at 12:56pm
I am getting "Load Report Failed" error when the .rpt files in temp folder is more. I am disposing the reports in Page_Unload event also. Sometimes the rpt files are cleared and sometimes not.
Please let me know any solution which helped to resolve this issue.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 25 Nov 2008 at 12:01pm
Does the error go away when you clear out the temp folder?  How much disk space is available on the drive where the temp folder is located?  I suspect you're running out of disk space.
 
Crystal is notorious for not cleaning up temp files, and has been for years.  Currently the only way around this is to do like Brian suggested and write a program or a .bat file that will go through and delete them - we use a .bat file that is run by the Windows Scheduler which deletes all of the files in the temp folder on Saturday evenings.
 
-Dell
IP IP Logged
Manas Sahu
Newbie
Newbie
Avatar

Joined: 09 Feb 2012
Location: India
Online Status: Offline
Posts: 1
Quote Manas Sahu Replybullet Posted: 09 Feb 2012 at 11:27pm
Hi hilfy,
 
I am also facing the similar type of problem of crystal report temp file. These temp are accumulated in the crystal report serer and eatting up huge amount of disk space. Could you please share the .bat file you are talking about. It will be very helpful for me.
 
Thanks in advance. :)
I can change the world but i do not have the source code.
IP IP Logged
jack_sparrow
Newbie
Newbie


Joined: 27 Mar 2012
Location: United Kingdom
Online Status: Offline
Posts: 1
Quote jack_sparrow Replybullet Posted: 27 Mar 2012 at 8:52am
Go to IIS Manager -> Connections -> Application Pools and select your application and under "Edit Application Pool", click Recycling.

Here you can define a recycling schedule which will remove any rpt or tmp file under Windows\Temp.

Edited by jack_sparrow - 27 Mar 2012 at 8:52am
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.031 seconds.