question

ShabbirHussain-8530 avatar image
0 Votes"
ShabbirHussain-8530 asked BruceZhang-MSFT commented

Crystal Reports objects disposal

Hi there,

We are facing issue while disposing crystal reports objects. Currently we are disposing crystal reports objects on page unload which deletes respective crystal report files from windows temp folder but at the same time we have noticed that on average temp files of 15 reports per day keeps on incrementing in temp folder which means that due to some reason report objects are not getting disposed properly. This leads to "Load report failed" error after a few days.

One reason could be the network failure due to which object disposal call back can't do its job.

Question is that is there any way we could dispose old crystal report objects from server through a script a batch or some IIS configuration to avoid "Load report failed" error for which we have to reset our IIS.

Thanks in advance,

windows-server-iis
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ShabbirHussain-8530 ,

Another way is to tweaking your system registry. Go to HKEY_LOCAL_MACHINE\SOFTWARE\CRYSTAL DECISIONS\10.0\REPORT APPLICATION SERVER\SERVER\PrintJobLimit (Ver 13.0) HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Report Application Server\InprocServer\PrintJobLimit (Ver 12.0). Change the "PrintJobLimit".

0 Votes 0 ·

1 Answer

cooldadtx avatar image
0 Votes"
cooldadtx answered

To be clear CR objects are in memory so when the process terminates the memory is cleared. If you don't do this explicitly then eventually they will get cleaned up as part of garbage collection but that is nondeterministic.

I believe cleaning up your resources in Unload is the correct place if you cannot clean them up earlier. But personally I never use this event. If you really want to ensure things get cleaned up then keep the object local to the function you need it in and wrap in a using statement. Then most problems go away. Do you really need the CR object to be a field in your page? In my experience this is generally a bad idea, just "create, use, release".

However I suspect the issue you're having isn't with the CR objects in memory but the files on disk not getting cleaned up because they are still in use. Most likely your CR objects are trying to clean up the files but that is failing so they are orphaned. I know nothing about CR so I cannot answer to how it works but if you have control over the creation of the files then mark them as temp files. Windows will automatically delete them when the last handle is closed on the file.

If that isn't an option but you do know the filenames then use the TempFileCollection class to manage the files. Add the files to the collection as they are created. When the collection goes away it auto-deletes any files it contains. This is very useful for temp files and we use it a lot.

However even in these cases it is possible for files to hang around either because they are still in use or the cleanup never happens such as if IIS forcefully terminates the worker process. Therefore you should always have a background process to clean up the files as well. You can use a simple script that is scheduled to run periodically and clean up files (say those older than an hour). This is most useful if you're creating many different files and want them all cleaned up. Alternatively if you want your app to be self-contained then on app startup create a worker service (or thread) that does the cleanup periodically instead. Either approach works well.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.