Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 730
  • Last Modified:

Export a Crystal Report to pdf - memory issues - CR9.0

I'm trying to export a crystal report file that has already been formatted etc.  All the code works except the subroutine adds just upwards of 2kb to mem usage and doesn't clean this afterwards.  The memory is added when the report object is assigned.  I know that the Get Object call doesn't work, and I don't know how to fix that either...just concentrate on the mem issue though.

        Dim oCrystalApp As CRAXDRT.Application

        Try
            oCrystalApp = GetObject(, "CRAXDRT.ApplicationClass")
        Catch ex As Exception
            oCrystalApp = New CRAXDRT.Application
        End Try

        Dim report As CRAXDRT.Report
        report = oCrystalApp.OpenReport(Server.MapPath(reportFileName), 1)   '<--------MEM ADDED TO STACK HERE!!

        report.MorePrintEngineErrorMessages = False
        report.EnableParameterPrompting = False
        report.DiscardSavedData()

        'SET REPORT PARAMETERS -- **(not included for scope of this question)

        report.VerifyOnEveryPrint = True
        report.ExportOptions.FormatType = 31 'pdf
        report.ExportOptions.DestinationType = 1 'put on the hd

        report.Export(False)

        report = Nothing
        oCrystalApp = Nothing


0
NateDizzle
Asked:
NateDizzle
  • 4
  • 4
1 Solution
 
mlmccCommented:
I believe these
        report = Nothing
        oCrystalApp = Nothing

should be

    set    report = Nothing
    set    oCrystalApp = Nothing

Also you may need to unload and set the form/viewer to nothing.

mlmcc

0
 
NateDizzleAuthor Commented:
oops, sorry, I'm using VB.Net so it is the same as using the 'Set' command.

I'm not using any form viewer.  I haven't instantiated anything to do with a form viewer at least...do I still need to touch that object? (the form viewer)
0
 
mlmccCommented:
Are you getting the PDF file exported correctly?

If you aren't using the viewer then no need to unload or set to nothing.

Since you are creating a new oCrystalApp object why use the getobject?  It should always return false.

mlmcc
0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
NateDizzleAuthor Commented:
I use the get object to prevent creating multiple applicationsm there are a number of different reports that the user can print during one session so I wanted to try this as a resolve to the memory leak....although I don't know the proper class name to reference.

The file is exported to pdf just fine, all the data is there and the format is flawless.  I don't know what the "1" does as the second parameter for the OpenReport function though.  I inherited this program and am making modifications and generally cleaning up flaws like this one.

N-Dizzle
0
 
mlmccCommented:
I forget what the 1 is for.

mlmcc
0
 
NateDizzleAuthor Commented:
meh, I don't think it matters.  I['m trying to convert all the crystal objects (the app and the report) to session objects as per a Crystal Decisions instruction manual I found does...we'll see if that helps.  Hopefully they at least terminate when the session expires.  Although I'm having a bit of trouble getting the session objects to work.  Unless someone has a solid answer don't bother posting anything, memory leaks are a bitch.

N-Dizzle
0
 
NateDizzleAuthor Commented:
Solution - The previous developer had used an older Crystal COM component.  Once I changed to the library associated with CR9 the memory issue was solved...and explicitely calling the report.close method, which was not included in the older library.

I found a ton of documentation on the Crystal Reports web site, it took some digging because their web navigation/interface isn't entirely intuitive.  Anyone with Crystal Reports problems should definitely check out their developers forum.

NateDizzle
0
 
mlmccCommented:
PAQ and refund

mlmcc
0
 
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now