cancel
Showing results for 
Search instead for 
Did you mean: 

Why I get an "out of memory" after loading like 32 760 reports?

Former Member
0 Kudos

Hi,

I have a WCF web service done in VB.Net with Visual studio 2010 and Crystal Report for Visual studio with runtime 13.0.6.1027. The web service need to generate 41000 reports in PDF , but after like 32760 reports, I always get an "Out of memory" message. I have the exact same problem of this archived post : https://archive.sap.com/discussions/thread/3622718 . I can simulate the same behavior with this simple application :

Try 
Dim i As Integer = 0 
While (i < 40000) 
    Dim monTestMemory As TestMemoryLeak = New TestMemoryLeak() 
    monTestMemory.Load("TestMemoryLeak.rpt") ' 
    monTestMemory.Close() 
    monTestMemory.Dispose() 
    monTestMemory = Nothing
    lblEtat.Content = "Rapport : " + i.ToString() i = i + 1
End While Catch ex As Exception
    MessageBox.Show(ex.Message + " " + ex.StackTrace) 
End Try

This simple application will always do an exception around the loading of the report 32760.

Someone have any idea how to make this to work?

Thank you in advance!!

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

The Crystal SDK is based on COM objects and .NET does not memory manage COM very well. You have to force it to release the memory, even though you're correctly using .Dispose(), by adding this line after .Dispose() and before assigning it to nothing:

Marshal.ReleaseComObject(MonTestMemory);

-Dell

Answers (1)

Answers (1)

0 Kudos

And time to upgrade to a more current version of the runtime:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Also from the error it suggest you are not releasing the Reports after each use and the count just keeps going up. Clean up your objects as Dell indicated.

Don