Quantcast
Viewing all articles
Browse latest Browse all 3636

ReportDocument.PrintToPrinter function Causes memory leak and Does not release temporary files.

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.


Viewing all articles
Browse latest Browse all 3636

Trending Articles