on 08-26-2014 4:16 PM
Hi All,
I have piece of code where I call the PrintToPrinter function to print the contents of the report to directly to printer. Here it prints the contents to the printer, But does not release the memory or temp files created while printing. It happens every time continuously. In fact I am even closing the report using the .Close and .Dispose functions. Still it is causing memory leak and leaves the temp files in the temp folder.
Here is the code that causes the problem.
public void PrintOut(int iCopies, bool bCollated, int iStart, int iStop)
{
rptDocument.PrintOptions.DissociatePageSizeAndPrinterPaperSize = false;
rptDocument.PrintToPrinter(iCopies, bCollated, iStart, iStop);
}
public void CloseReport()
{
frmPrintPreview.Close();
frmPrintPreview.Dispose();
rptDocument.Close();
rptDocument.Dispose();
}
Any help from any body would be greatly appreciated.
What version of .NET?
What version of CR (please be precise - include Service Pack level)?
What utility are you using to determine there is a memory leak? What is leaking - handles, etc.?
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ludek,
Thanks for your reply. And here are the details.
.NET version : Crystal Report for .NET Framework 4.0
Crystal Report version : Crystal report for Visual Studio 2010 (SP8)
I am not using any utility, I could see the memory consumption in the Task Manager. Also I could see it is not releasing the temporary files from the TEMP folder. The memory gets cleared only when I close the application window.
I hope this provides some more insight in to my problem.
And Thanks in Advance.
Hi Gallen
First, let's get you to SP 10:
Next, see if doing the code as this will help:
public void PrintOut(int iCopies, bool bCollated, int iStart, int iStop)
{
rptDocument.PrintOptions.DissociatePageSizeAndPrinterPaperSize = false;
rptDocument.PrintToPrinter(iCopies, bCollated, iStart, iStop);
rptDocument.Close();
rptDocument.Dispose();
}
- Ludek
Are all of the temp file being deleted when you close the application?
Also, iterate through about 100 report objects and see if the memory stabolizes, doing one or 2 doe snot give the OS time to actually clean up.
If you let the app and your PC sit idle for an hour or more does the memory get released?
Try adding GC.COllect also, this forces Windows to release everything marked as free sooner then later.
Don
Ludek, Thanks again.
I tried the above code but still, it is not releasing the temp files, or memory while directly printing to the printer.
We understood that SAP API's are clearing the temp files and memory once the Print Job or Print to Preview is done. But in our case after the Print operation we have noticed the temporary files and memory is not cleared. But this is not the case when Print to Preview is executed using CrystalReportViewer class, here both temp files and memory is cleared.
It would be appreciated if you could suggest any SAP Crystal report API to explicitly to clear the print related temp files in temp folder?
Thanks.
Hi Gallen,
Check your AV software, it's likely blocking CR from deleting the temp files. As ludek also said, all temp files are under the control of crpe32.dll and it does clean up it's temp files. So likely some third party software or permissions is blocking CR from cleaning up those files. Check your AV software logs to see if mentions anything.
Also, just to confirm what is an example of the file names you are seeing left behind? Just to confirm they do belong to CR.
Don
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.