In the Visual Studio 2012 version of Crystal Reports 13 there is a threshold that throttles concurrent reports, this also includes sub reports, to 75 reports across a machine. This means if there are 5 web applications on a given server all opened reports across all 5 web applications counts toward the 75 report limit.
The error manifests itself in different ways and may result in the following errors “Not enough memory for operation.” or “The maximum report processing jobs limit configured by your system administrator has been reached”.
The problem is the reports are not disposed and they continue accumulate until the 75 limit is hit. To fix this issue, the reports have to be disposed of at the earliest possible time. This sounds simple, but is not as straightforward as it seems. Depending how the reports are generated there are two scenarios: First is generating PDF’s or Excel spreadsheets and the second is using the Crystal Report Viewer. Each scenario has a different lifetime, which we need to take into account when crafting our solution.
private bool disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
context.Dispose(); //context means your crystal report document object.
}
}
this.disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
SOLVED
CurrentJobLimit
is a counter of concurrent reports.
This counter is not well managed, so it can easily increase, also if real number of reports is lower.
I solved the problem closing the Crystal Report Document programmatically.
protected void Page_Unload(object sender, EventArgs e)
{
CrystalReportViewer1.ReportSource.Close();
}
Anyway, the number of 75 can be increased by registry:
HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit
(but this is just a workaround....)
I've got a old piece of code that was auto-generating the host WinForm form for Crystal Reports, that had a specific line to call Close()
on the report class as the form was closing, I'm pretty sure that was because of disposing issues. So might be the case here?
This was probably for an older version of Crystal too, so might be a red herring.
I think you should try
- rep.Close()
- rep.Dispose()
- CrystalReportViewer1.Dispose()
*my function
Protected Sub close_and_dispose_report(ByRef r As ReportDocument)
If Not r Is Nothing Then
r.Close()
r.Dispose()
CrystalReportViewer1.Dispose()
End If
End Sub
when navigate to other page
Protected Sub Page_Unload(sender As Object, e As EventArgs) Handles Me.Unload
Me.close_and_dispose_report(rep)
End Sub
when close web page
Protected Sub Page_Disposed(sender As Object, e As EventArgs) Handles
Me.Disposed
Me.close_and_dispose_report(rep)
End Sub