Memory full error when exporting crystal report to pdf

天大地大妈咪最大 提交于 2021-01-28 12:14:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!