问题
we have a legacy application written in visual basic 6.0. This application first saves the rendered crystal report into a directory as a pdf document. Then we take that document and store in database as a blob. Following is a snippet of the code. When the application has to render reports for say 1000 employees, it runs half-way through and throws "Memory full" error on ".Export false" line. If I hit play button after it throws the exception, it works fine. But, someone has to watch for it and hit the play button. Any suggestions on how to fix this?
FileLocation = "D:\TempSaveToMail\" & CoCode & Batch & ".pdf"
On Error Resume Next
Kill FileLocation
On Error GoTo 0
myReport.ExportOptions.DiskFileName = FileLocation
myReport.ExportOptions.DestinationType = crEDTDiskFile
myReport.ExportOptions.FormatType = crEFTPortableDocFormat
myReport.ExportOptions.PDFExportAllPages = False
myReport.ExportOptions.PDFFirstPageNumber = StartPage
myReport.ExportOptions.PDFLastPageNumber = EndPage
myReport.Export False
' Make printer friendly check the PDF image
ImageReferenceNumber = InsertImage(CoCode, FileLocation)
ReferenceNumber = GetReferenceNumber(CoCode, EmpNo, CheckNumber, Batch)
InsertPDFImages CoCode, EmpNo, Batch, ReferenceNumber, ImageReferenceNumber
回答1:
You are not disposing your report objects resulting in memory leaks
After each employee dispose your report using
for each employee
myreport = new report
//do all processing here
myReport.dispose
next employee
This should work
来源:https://stackoverflow.com/questions/30960575/memory-full-error-when-exporting-crystal-report-to-pdf