Posted 14 September 2017, 6:41 pm EST
[activereports_archive]Now that I’m using SectionReports, I’m getting a System.OutOfMemoryException at the end of deploying (the report doesn’t display).
I searched over the internet, and the documentation, and I found a very interesting solution, which is using the disk cache to reduce memory use.
It’s mentionned that this would be useful if the report had more than 100 pages, otherwise it’s useless.
Now in a normal scenario, it would be implemented this way:
[csharp]
protected void ShowReport()
{
rpt = new SectionReport();
rpt.Document.CacheToDisk = true;
rpt.Document.CacheToDiskLocation = "C:\Temp";
rpt.Run();
webViewer.Report = rpt;
}
[/csharp]
In my case, I have 2 parametered SectionReports, that I merge for each instance of the parameter, if they meet certain conditions (that’s why I need to loop and run both reports for every parameter’s value).
A single parametered report doesn’t result in more than 10 pages.
Here’s my code:
[csharp]
protected void ShowReport()
{
PagesCollection pc = new PagesCollection();
// this will loop for at least 15 000 times, and it takes about 3 and a half hour
foreach (string _param in _params)
{
rpt1 = new SectionReport1(_param);
rpt1.Run();
rpt2 = new SectionReport2(_param);
rpt2.Run();
if(rpt2.meetsConditions == true && rpt1.meetsConditions == true)
{
pc.AddRange(rpt1.Document.Pages);
pc.AddRange(rpt2.Document.Pages);
}
}
rpt1.Document.Pages.Clear();
// pc will contain at least 30 000 pages
rpt1.Document.Pages.AddRange(pc);
webViewer.Report = rpt1;
}
[/csharp]
Could anyone tell me please where to implement this solution in my code?
P.S. The code is working fine when looping on fewer parameters.[/activereports_archive]