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


NateDizzleAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.