cancel
Showing results for 
Search instead for 
Did you mean: 

Correct way to Close a doc object to ensure memory is freed up

Former Member
0 Kudos

Hi

We have been developing a web reporting web site to hang off our bespoke management app and so far all had been working fine.

But recently we are getting regular errors thus

'The maximum report processing jobs configured by your system administrator has been reached'

After much Googlising it seems this is due to me not correctly closing the report document after finishing with the viewer. I read this article as the basis for my assumption

http://devlibrary.businessobjects.com/businessobjectsxir2/en/en/CrystalReports_dotNET_SDK/crsdk_net_...

My code works by using non-embedded reports (external files) that are assign (Load) to a ReportDocument object which is in turn placed in a session variable and a new browser wind is opened (using Javascript) which opens the page with the viewer on it. The page with the viewer then reads the session object and assigns the ReportDocument contained within it to the ReportSource property of the viewer.

I can post the code if required.

My question is (are)

1. Is this an OK way to do things generally?

2. Once I am on the viewer page and have assigned the session variable (ReportDocument) to the ReportSource of the viewer, how can I then safely and fully close the document to ensure the memory is freed up? As It have passed the ReportDocument over is a session variable I am guessing I no longer have access to the original object (created on a different page) to ensure it gets released properly?

3. Or am I on the wrong track entirely as to the cause of this issue?

Many thanks in advance

Regards

Mark

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Mark,

Best way is to simply add the close/dispose on the page unload event. If you are using Datasets or other objects be sure to close them also.

It's not really required now because the engine does it but adding a GC.Collect on the unload event forces the OS to clean up the memory "now"...

The biggest issue is Microsoft's memory handler, it's a piece of C@!#... It leaves the memory fragmented and CR requires Contiguous memory space. Unix and those types of OS's have proper memory handlers and they defrag the memory on the fly, MS doesn't...

Unfortunately .NET doesn't work on those OS's.... And going pure Java has it's problems also....

Only option is to do as Microsoft highly recommends, cycle the App and WEB server at least once a week so the OS's can clean up and releases all of it's memory...

Don

Former Member
0 Kudos

Hi Don

Thanks for the help. Sounds like this is more of a headache than I had expected!

I am still not clear about being sure that the Close of the object will work given the way I am doing things. The main bit I am not sure about is in point 2 of my question above.

My document is in a session variable to pass over to another page (with the viewer on it). I am not clear if I clear that session variable, will it kill of the underlying ReportDocument, or can I access the original ReportDocument object via the ReportViewer object and clear it out that way?

In any event it seems that I should also do a GC.Collect in the page unload as well??

Thanks

Mark

Former Member
0 Kudos

Hi

I have made numerous changes to the code we are using and we are still regularly getting the

The maximum report processing jobs limit configured by your system administrator has been reached.


error

I have place

crRptDoc.Close

crRptDoc.Dispose

In the unload event of the page that has the viewer on it. However I have noticed some strange behaviour with event firing (seems odd to me anyway). If I place a breakpoint on the first line of the Page Init and the first line of the Page Unload the sequence of events is thus

Page Init fires, first breakpoint is hit, then the code in the Init event runs (sets up the document, sets the datasource etc)

then

Page Unload fires, doc close & dispose are run

then the report is displayed.

Seems odd that unload fires before the report is displayed, right after the init event???

Then, when I close the page with the report viewer on it (just click on the browser window red cross button in corner), the unload event does not fire.

Can you help me understand what is happening here please?

And can you suggest what else I can do to stop getting the job limit error?

Thanks

Mark

Message was edited by: Ludek Uher

Former Member
0 Kudos

HI

i am getting a lot of stick from my customer about this issue.

Can someone help at all pls?

thanks

MArk

0 Kudos

What version of the runtime are you using?

What Os is the app running on?

What Dev language did you write it in?

windows or WEB app?

Don

Former Member
0 Kudos

Hi

Crystal for VS V13.0.2 is what is installed in my dev environment. How do I find what the engine version runtime is installed on the web server?

OS is Win Server 2008 R2 64 Bit. The app is compiled 32 bit only

Dev is done in ASP.NET with VB.NET code behind

Web app running on iis7 on the server

Thanks
Mark

0 Kudos

Hi Mark,

Search for crpe32.dll, then properties, it will tell you the version. First nunmber is the primary version ( 13 for CR for VS ), next number is 0, third number it the Service Pack level, and finally the minor version number.

Depending on the version depends on why, CR Basic or standalone .NET CR runtime has a built in limit of 3 CPL's meaning only 3 report objects can be processed at one time. But typically there are not 3 reports running at the exact same time but there can be depending on their complexity... If there is then try changing these keys located in or similar depending on the version:

HKEY_LOCAL_MACHINE\SOFTWARE\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Report Application Server\InprocServer

PrintJobLimit = 0 ( unlimited ) I don't recommend this though, there should be some limit. 50 is actually better but depends, you'll have to play to find what works for you without errors.

PrintJobSharingTimeout = 20 - Try setting this key to 1, this controls how long the engine will keep a report cached. The minimum is actaully 2 minutes and will set itself to less than 2.

If you are not using RAS (ReportClientDocument) then these keys will not affect the Opening/closing. And the Engine (ReportDocument) is limited to 3 CPL's, absolutely no coding way around this. Others have created WEB farms though to manage this with a load balancer ( must be Sticky Sessions ).

Another thing is Microsoft recommends to cycle the IIS Server at least once a week so it can clear up the memory manager. More often depending on the usage. It's can't defrag memory and CR requires contiguous memory blocks.

So I believe you are doing everything correctly, issue is with IIS and it's memory handler... UNIX OS's don't have this problem, they defrag the memory on the fly. Only way for MS to defrag is to reboot the server.

Don

Answers (0)