Skip to Content
0

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

Mar 27 at 05:51 PM

42

avatar image

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!!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Dell Stinnett-Christy Mar 29 at 05:13 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Don Williams
Apr 05 at 04:17 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded