Skip to Content
avatar image
Former Member

Crystal Report 2013 memory problem

Hi,

I am developing a Windows service. The service calls Crystal Report to generate PDFs. When a new contract appears in database (MS Access), the service reads contract number and build a formular. Then pass the formular to ReportDocument. The code looks like this

using (ReportDocument report = new ReportDocument()) {

report.Load("contract.rpt");

// some initialize report

foreach (var contract in contracts) {

report.RecordSelectionFormula = BuildFormular(contract);

report.ExportToDisk(ExportFormatType.PortableDocFormat, BuildOutputFilename(contract));

}

report.Close();

}

It works fine. When deploy on production, I want the location of Access file can be changed programmatically. So I modified the code

using (ReportDocument report = new ReportDocument()) {

report.Load("contract.rpt");

// some initialize report

foreach (ReportDocument subreport in report.Subreports) {

foreach (Table table in subreport.Database.Tables) {

table.Location = MdbPath;

}

}

foreach (Table table in report.Database.Tables) {

table.Location = MdbPath;

}

foreach (var contract in contracts) {

report.RecordSelectionFormula = BuildFormular(contract);

report.VerifyDatabase();

report.ExportToDisk(ExportFormatType.PortableDocFormat, BuildOutputFilename(contract));

}

report.Close();

}

It works but memory increases over time. Here are Private Bytes (I use Performance Monitor tool)

  • 10:45 - 58.000MB
  • 11:00 - 61.801MB
  • 11:15 - 64.611MB
  • 11:30 - 65.544MB
  • 11:45 - 65.716MB
  • 12:30 - 69.095MB

I also attached some screenshot of report of DebugDiag tool.

My environment:

  • Net framework 4.5
  • Tool runs as Windows Service
  • Crystal Report 2013 (Crystal Report Runtime 32bit 13.0.10.1385).
  • Database: MS Access/OleDb

Any suggestion?

Many thanks

summary.PNG (67.3 kB)
Finalizer.PNG (43.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Sep 08, 2014 at 04:37 PM

    Remove report.VerifyDatabase();


    Not needed and only slows down the performance of the report engine.


    Under report.Close();


    add


    report.Dispose;


    You may want to see if adding GC.Collect will be of any use also.



    - Ludek

    Senior Support Engineer AGS Product Support, Global Support Center Canada

    Follow us on Twitter

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Vi,

      We do take memory leak seriously but as you can see below.... Cr is the least of problem...

      I downloaded a trial version of Rational Purify and here's the results:

      Purify for Windows,

      (C) Copyright IBM Corporation. 1992, 2012. All Rights Reserved.

      Version 7.0.1.0-003 Evaluation 32-bit ; Build: 20120705.2308;

      Windows Server 2008 R2 Enterprise 6.1 7601 Multiprocessor Free

      Instrumenting:

      CrystalMemleak.exe 6144 bytes

      Purify: While processing file C:\CrystalMemleak\bin\Release\CrystalMemleak.exe:

      Warning: This native code executable statically links managed or mixed code module(s).

      Purify does not support this configuration when inclusive instrumentation

      is used.For more info, see the topic "Inclusive Instrumentation" in the Purify

      online help.

      NTDLL.DLL 1292192 bytes

      ADVAPI32.DLL 640512 bytes

      ADVAPI32.DLL 640512 bytes

      MSCOREE.DLL 297808 bytes

      MSVCRT.DLL 690688 bytes

      Purify: While processing file C:\Windows\SysWOW64\MSVCRT.DLL:

      Note: Instrumentation repeating with 7 additional entry points.

      KERNELBASE.DLL 274944 bytes

      SECHOST.DLL 92160 bytes

      SECHOST.DLL 92160 bytes

      KERNEL32.DLL 1114112 bytes

      RPCRT4.DLL 663552 bytes

      RPCRT4.DLL 663552 bytes

      PCWUM.DLL 33280 bytes

      PCWUM.DLL 33280 bytes

      CRYPTSP.DLL 78848 bytes

      CRYPTSP.DLL 78848 bytes

      SSPICLI.DLL 96768 bytes

      SSPICLI.DLL 96768 bytes

      CRYPTBASE.DLL 36864 bytes

      CRYPTBASE.DLL 36864 bytes

      As you can see CR is leaking 6144 bytes

      Nothing we can do about this, I doubt R&D will look for 6144 bytes...

      Don