Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Report with many images (2000+) will crash with out of memory exception
posted

I have a report that has a grid with data and multiple images.  The report will show 5 images per grid row with possibly many rows.  The amount of data is dynamic.

As the report grows its memory footprint also grows to the point where the app will crash with an out of memory exception.

I have tried compressing the image using the JPeg Encoder and have tried monitoring memory, publishing the report, creating a new report in an effort to start over and clear memory.

I have added GC.Collect, GC.WaitForPendingFinalizers(), GC.Collect() after publishing but the memory never decreases.  It's as if the Report is holding on to everything.

While it does help a little with memory eventually the app will crash because of the Out of Memory exception.

I've seen similar posts to this issue but none fixes the problem.

Is there any way to solve this? 

Parents
  • 29105
    Offline posted

    Hello James, 

    Thank you for contacting Infragistics. You can try setting a FileBuffer on the UltraGridDocumentExporter, which is a file where data can be cached during a publish operation.

    // AutoSize the grid columns and rows when exporting
    this.ultraGridDocumentExporter1.AutoSize = Infragistics.Win.UltraWinGrid.DocumentExport.AutoSize.SizeColumnsAndRowsToContent;
    
    // Use a file buffer
    this.ultraGridDocumentExporter1.UseFileBuffer = true;
    
    // Specify a file instead of letting the control use the temp folder.
    string bufferFileName = Path.Combine(Application.StartupPath, "ExportFileBuffer.tmp");
    this.ultraGridDocumentExporter1.FileBuffer = bufferFileName;
    
    // Set the target paper orientation, size, and margins
    this.ultraGridDocumentExporter1.TargetPaperOrientation = PageOrientation.Portrait;
    this.ultraGridDocumentExporter1.TargetPaperSize = PageSizes.Legal;
    this.ultraGridDocumentExporter1.TargetPaperMargins = PageMargins.Normal;
    
    // Export the grid to a PDF file.
    string exportFileName = Path.Combine(Application.StartupPath, "grid.pdf");
    this.ultraGridDocumentExporter1.Export(this.ultraGrid1, exportFileName, GridExportFileFormat.PDF);
    
    // Launch the exported file in the appropriate reader. 
    Process.Start(exportFileName);

    If you are creating a single report that is crashing then there is always going to be a limit to the size of the report you can create in memory. There’s no way around that. 

    The idea behind the recommendation above is so the exporter uses a file to store information during a publish operation and possibly relieve memory. So that might help if the crash occurs while publishing but not if the crashing occurs while creating the report is already in memory and you are making changes or adding things. 

    If you are still having issues, please provide a sample application that isolates/reproduces the behavior. 

    Have a nice day!

Reply Children