0

Our software needs to produce variable-sized reports, which can easily move past 100 pages. Several of these pages contain large images/Bitmaps.

Is there a reliable way to prevent the overall report from consuming all available memory? Once we have enough pages being generated, the app almost never finishes creating the report without running out of memory. Most of the memory is consumed by Bitmaps that we cannot release. (Attempting to dispose of them before the report is complete causes the report generation to fail.)

Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
John Fisher
  • 22,355
  • 2
  • 39
  • 64
  • 64-bit operating systems are mainstream today. Talk to the vendor if that's not feasible for some reason. – Hans Passant Mar 17 '14 at 20:39
  • @HansPassant: The software is already running on a 64-bit OS. Windows doesn't let you use all the system memory - particularly for GDI operations. Also, this *is* an attempt to contact people who know how to use ActiveReports. – John Fisher Mar 17 '14 at 21:23

3 Answers3

2

John

Have you tried using the cache to disk with ActiveReports?

http://helpcentral.componentone.com/nethelp/AR7Help/OnlineEn/CacheToDiskAndResourceStorage.html More details here: http://helpcentral.componentone.com/nethelp/AR7Help/OnlineEn/GrapeCity.ActiveReports.Document.v7~GrapeCity.ActiveReports.Document.SectionDocument~CacheToDisk.html

Set this up prior to running the report. For example: report.Document.CacheToDisk = true; report.Run();

Rajnish Sinha
  • 406
  • 2
  • 4
  • It looks like CacheToDisk is the only help that ActiveReports provides. I was hoping for more guidance around large images, but it appears that there really isn't much to be had. – John Fisher Mar 27 '14 at 15:18
0

I think you could try spliting ur report into smaller chunks ,run them and then merge all the reports into one once all pages have been generated.

json
  • 1
  • Yeah, but that doesn't seem to fit with the way that ActiveReports was designed to be used. They even mention in the documents that it should handle large reports, but I haven't seen anything particularly helpful around images. – John Fisher Mar 19 '14 at 18:46
0

One more suggestion in addition to setting CacheToDisk property of ActiverReports to True would be to make use of Image.FromStream instead of Image.FromFile to access the images.

Image.FromFile leaves file handles open, and hence it may result in the Memory Exception.

using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
   using (Image original = Image.FromStream(fs))
   {
      ...
   }
}

Using an explicit Dispose(), a using() statement or setting the value to null on the bitmap doesn't generally solve the issue with Image.FromFile.

So if you App runs for a time and opens a lot of files consider using Image.FromStream() instead.

Regards, Mohita

Mohita
  • 499
  • 3
  • 4