Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Crystal Reports for .NET v13 SP13 still leaks handles

Hi,

We're running into a problem with SAP Crystal Reports for .NET; looks like it still leaks handles.

The application is written in Visual Studio 2010 SP1Rel (C#), and all Crystal reports files are developed in Crystal Reports 2011 SP4 14.0.4.738.

Crystal reports for .NET runtime has SP13.

Multiple report calls caused the application to hang. It was found out that reportDocument.Load() method call never returns.

The first thought was that it's due to multiple threads locking resources. But after narrowing it down by running single thread in test environment we came to conclusion that the problem occurs in .Close() method.

In a test code we call reportDocument.Load() method in a loop, properly close and dispose reportDocument each time (with garbage collection enforcement).

private void Form1_Load( object sender, EventArgs e )

{

     var t1 = new Thread( () => TestLoad( @"D:\test.rpt" ) );

     t1.IsBackground = true;

     t1.Start();

}

private void TestLoad( string filePath)

{

     var count = 0;

           

     while ( true )

     {

          var doc = new ReportDocument();

          doc.Load( filePath );

          count++;

          doc.Close();

          doc.Dispose();

          GC.Collect();

      }

}

The test runs different number of iterations (based on machine it varies from 500 to 8000 times).

As you can see there are no concurrent runs, all reports run in sequential order. The hang always happens in doc.Close() method.

When we modified the code to run 2 threads, each thread ran half of the single thread number, but total number of loops usually remains the same (with some variation).

When running 2 threads, the second thread always hangs during doc.Load() method if another thread hanged with .Close() method.

The memory dump (1 thread, around 8500 iterations):

Thread   9

Current frame:

ChildEBP RetAddr  Caller, Callee

0630f2f8 08da2996 (MethodDesc 06205ab8 +0x5e DomainBoundILStubClass.IL_STUB_PInvoke())

0630f310 08da2996 (MethodDesc 06205ab8 +0x5e DomainBoundILStubClass.IL_STUB_PInvoke())

0630f32c 08da28e5 (MethodDesc 06202cb0 +0x75 CrystalDecisions.CrystalReports.Engine.CRPE.CloseCrpe())

0630f374 0034f872 (MethodDesc 00463654 +0x82 CrystalDecisions.CrystalReports.Engine.ReportDocument.InternalClose(Boolean))

0630f3d0 0034f7d5 (MethodDesc 0046363c +0x3d CrystalDecisions.CrystalReports.Engine.ReportDocument.Close())

0630f3d8 653357fa (MethodDesc 64c1f3c8 +0x72 System.Windows.Forms.Control.Invoke(System.Delegate, System.Object[]))

0630f414 003426fd (MethodDesc 00461de0 +0x135 WindowsFormsApplication1.Form1.TestLoad(System.String, System.String))

0630f488 003424f6 (MethodDesc 00461e10 +0x36 WindowsFormsApplication1.Form1.<Form1_Load>b__0())

0630f4d0 675b6ea7 (MethodDesc 67379474 +0x6f System.Threading.ThreadHelper.ThreadStart_Context(System.Object))

0630f4dc 67594157 (MethodDesc 672b75c8 +0xa7 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))

0630f540 67594096 (MethodDesc 672b75bc +0x16 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))

0630f554 67594051 (MethodDesc 672b75b0 +0x41 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))

0630f570 675b6e28 (MethodDesc 672ca6b4 +0x44 System.Threading.ThreadHelper.ThreadStart())

The memory dump (2 thread, around 4200 iterations each):

Thread  10

Current frame:

ChildEBP RetAddr  Caller, Callee

0705efe4 0041ba82 (MethodDesc 072028b4 +0x62 CrystalDecisions.CrystalReports.Engine.CRPE.InitCrpe())

0705f060 0041adad (MethodDesc 005bd140 +0x20d CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened())

0705f120 0041a5c9 (MethodDesc 005b370c +0x699 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(System.String, CrystalDecisions.Shared.OpenReportMethod, Int16))

0705f2a8 00419e65 (MethodDesc 005b3730 +0xb5 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(System.String))

0705f314 00412730 (MethodDesc 005b1de0 +0xb8 WindowsFormsApplication1.Form1.TestLoad(System.String, System.String))

0705f388 00412556 (MethodDesc 005b1e10 +0x36 WindowsFormsApplication1.Form1.<Form1_Load>b__0())

0705f3d0 675b6ea7 (MethodDesc 67379474 +0x6f System.Threading.ThreadHelper.ThreadStart_Context(System.Object))

0705f3dc 67594157 (MethodDesc 672b75c8 +0xa7 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))

0705f440 67594096 (MethodDesc 672b75bc +0x16 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))

0705f454 67594051 (MethodDesc 672b75b0 +0x41 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))

0705f470 675b6e28 (MethodDesc 672ca6b4 +0x44 System.Threading.ThreadHelper.ThreadStart())

---------------------------------------------

Thread  11

Current frame:

ChildEBP RetAddr  Caller, Callee

0730ea18 0041bbf9 (MethodDesc 07202d84 +0x69 DomainBoundILStubClass.IL_STUB_PInvoke(CrystalDecisions.CrystalReports.Engine.PEEngineOptions ByRef))

0730ea34 0041bbf9 (MethodDesc 07202d84 +0x69 DomainBoundILStubClass.IL_STUB_PInvoke(CrystalDecisions.CrystalReports.Engine.PEEngineOptions ByRef))

0730ea54 0041bb39 (MethodDesc 072028b4 +0x119 CrystalDecisions.CrystalReports.Engine.CRPE.InitCrpe())

0730ead0 0041adad (MethodDesc 005bd140 +0x20d CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened())

0730eb90 0041a5c9 (MethodDesc 005b370c +0x699 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(System.String, CrystalDecisions.Shared.OpenReportMethod, Int16))

0730ed18 00419e65 (MethodDesc 005b3730 +0xb5 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(System.String))

0730ed84 00412730 (MethodDesc 005b1de0 +0xb8 WindowsFormsApplication1.Form1.TestLoad(System.String, System.String))

0730edf8 004125a6 (MethodDesc 005b1e1c +0x36 WindowsFormsApplication1.Form1.<Form1_Load>b__1())

0730ee40 675b6ea7 (MethodDesc 67379474 +0x6f System.Threading.ThreadHelper.ThreadStart_Context(System.Object))

0730ee4c 67594157 (MethodDesc 672b75c8 +0xa7 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))

0730eeb0 67594096 (MethodDesc 672b75bc +0x16 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean))

0730eec4 67594051 (MethodDesc 672b75b0 +0x41 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object))

0730eee0 675b6e28 (MethodDesc 672ca6b4 +0x44 System.Threading.ThreadHelper.ThreadStart())

Any help will be appreciated.

Igor

Former Member
replied

Hi Igor,

All I can suggest is you try hitting the DB directly, using Datasets is very memory intensive.

Also, your test app is replicative of your main app or are you simply running this report until you run out of System resources?

Report bursting is not supported by this SDK, it's all INPROC,

If you must hot the report that many time then move to CRSE OEM, CRS or BOE and use either multiple RAS Services or in CRS or BOE 4.1you can use the Job Server or Page Server. They spawn separate thread for each report and closes it when done.

Or other option is to thread your own app and do the same.

CR for VS was never designed to burst report jobs, we know it can not handle the loading and it was not designed to do it.

Don

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question