Memory Leakage problem with StiReport.

Stimulsoft Reports.NET discussion
Post Reply
roomy
Posts: 61
Joined: Mon May 06, 2013 12:34 pm

Memory Leakage problem with StiReport.

Post by roomy »

I have multiple mrt report in my project all working fine and all reports are looks good as well.
But Memory Leakage problem Stuck my application regurally. I try to use number of opetion to over come this issue but problem still exist. Will you please suggest how can I manage Report object in my code and Dispose it after creating complete report and keep the memory leakage null or minimum.

This is my code lines which I use to create report.

Code: Select all

public void SubReport()
{
      StiReport report = new StiReport();
      DataSet ds = new DataSet();
      try
      {
        report.Load(templatePath);
        DataTable dtData = CreateDataTable(ReportType);
        string stHeader = dtData.Rows[0][0].ToString();
        StiText Header = report.GetComponents()["txtHeader"] as StiText;
        Header.Text = stHeader;
        StiText Disclaimer = report.GetComponents()["txtDisclaimer"] as StiText;
        Disclaimer.Text = dtData.Rows[0][1].ToString();
        DataCls data = new DataCls();
        string xmlData = data.getAnnuityData_Level_02(DataConvert.SelectedProductXML(SelectedProductIDs, m_age, m_state, m_qualifiedAnnuity));
        StringReader theReader = new StringReader(xmlData);
        ds.ReadXml(theReader);
        
        report.RegData(ds);
        report.Dictionary.Synchronize();
        report.Compile();
      }
      catch (Exception ex)
      {
      }
      finally
      {
        report.Dispose();
        ds.Dispose();
      }
      return report;
}
and I use a marter Report object to join all reports pages to gether that is:

Code: Select all

JoinReports.SubReports.Add(Subreport);
At the end I export it in pdf format.

Code: Select all

 StiPdfExportSettings settings = new StiPdfExportSettings();
        settings.ImageQuality = 1F;
        settings.ImageResolution = 500;
        JoinReports.ExportDocument(Stimulsoft.Report.StiExportFormat.Pdf, reportPath, settings);
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Memory Leakage problem with StiReport.

Post by HighAley »

Hello.

Please, read next forum topic http://forum.stimulsoft.com/viewtopic.php?&t=131
Then read an article from our Blog http://blog.stimulsoft.com/articles/som ... led-report

What are you trying to do with your code. Please, describe your issue more detailed.
We will advise you the right solution.

Thank you.
User avatar
Fabio Pagano
Posts: 355
Joined: Mon Apr 16, 2007 12:38 pm
Location: Bari (Italy)

Re: Memory Leakage problem with StiReport.

Post by Fabio Pagano »

The blog link is the same of forum topic. I'm interested about the argument, please correct with the blog article link.

Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Memory Leakage problem with StiReport.

Post by HighAley »

Hello.

Sorry, we have corrected the link.

Thank you.
roomy
Posts: 61
Joined: Mon May 06, 2013 12:34 pm

Re: Memory Leakage problem with StiReport.

Post by roomy »

Thanks its good, But I want to know the cause behind this memory leakage? I try Assambly and appdomain method but still having leakage in memory. :(

The use of assambly reduce the compilation overhead and load the report once. I really want to know more about this memory leakage problem with stimulsoft.

Thanks
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Memory Leakage problem with StiReport.

Post by HighAley »

Hello.

There are some problems in .Net Framework Garbage Collector. Sometimes it does not collect the unused objects.
So it's better to use Dispose() method for StiReport instance.
Every occasion needs more detailed consideration. Please, send us a sample project which reproduces the issue for analysis.

Thank you.
roomy
Posts: 61
Joined: Mon May 06, 2013 12:34 pm

Re: Memory Leakage problem with StiReport.

Post by roomy »

I have already have Dispose() and set object null at the end for all the report object in my application and I am using finally block for that but the problem remain same in my all web application. it is not an easy task for me to provide you a sample from my running application. But I really need some solution for that problem. Other things are working fine in my all reports project.

Code: Select all

try
{
....
.....
}
catch
{
......
.....
}

finally
{
 Stireport.Dispose();
if(Stireport != null)
    Stireport=null;
}
Thanks...
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Memory Leakage problem with StiReport.

Post by HighAley »

Hello.

Sorry, but we can't help you while we don't reproduce the issue.
Maybe this article will help you to prepare a sample project

Thank you.
roomy
Posts: 61
Joined: Mon May 06, 2013 12:34 pm

Re: Memory Leakage problem with StiReport.

Post by roomy »

I go through that article and try to simplify but it’s impossible to create the exact scenario. Please find the attachment. In report mostly 50 to 150 pages report and use different templates and joint report objects to create final report.
DUMP.rar
(50.07 KiB) Downloaded 271 times
Thank You
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Memory Leakage problem with StiReport.

Post by Alex K. »

Hello,

We gave you some tips to improve your application in using compiled reports in previous posts.

You have sent us an example in what, first, there are no our recommendations, and, second, there is no use of the method Dispose(). So the memory leak will occur. Please follow our recommendations.

Thank you.
Post Reply