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?
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!
I should have qualified my question. I am using the Document engine to generate a PDF report. The grid I reference is the IGrid. In it I place about 6 columns with text then grid rows with 5 columns each having an image. Each image size is 100x70. Adding the images causes the report to grow until it crashes with an out of memory exception. Publishing the report and reinitializing with report = new Report() does not help, even with calls to the GC.Does the Report have an offline storage option like the grid you mentioned?
The FileBuffer property is exposed on objects such as the Report but I haven't tried this.
https://ko.infragistics.com/help/winforms/infragistics.documents.reports~infragistics.documents.reports.report.report~filebuffer
If you can provide a sample it will give us a better idea at what else to look for.
The FileBuffer on the Report object doesn't do anything - I tried it. It does create the tmp file but it never gets populated. So I'm guessing it has another purpose.
My only real recourse at this point is to limit the number of images in the report. It is a shame that I have to do this to get around a short-coming in the Report module.
Are there any plans to fix this? Are there any secrets that can be used to get past this problem?
Can you provide a stack trace and a sample? We aren't already aware of this behavior.