Page 1 of 1

Memory Leakage problem with StiReport.

Posted: Wed Feb 05, 2014 4:43 am
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);

Re: Memory Leakage problem with StiReport.

Posted: Wed Feb 05, 2014 10:26 am
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.

Re: Memory Leakage problem with StiReport.

Posted: Wed Feb 05, 2014 5:26 pm
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.

Re: Memory Leakage problem with StiReport.

Posted: Thu Feb 06, 2014 6:00 am
by HighAley
Hello.

Sorry, we have corrected the link.

Thank you.

Re: Memory Leakage problem with StiReport.

Posted: Thu Feb 06, 2014 10:30 am
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

Re: Memory Leakage problem with StiReport.

Posted: Fri Feb 07, 2014 10:02 am
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.

Re: Memory Leakage problem with StiReport.

Posted: Fri Feb 07, 2014 10:28 am
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...

Re: Memory Leakage problem with StiReport.

Posted: Fri Feb 07, 2014 2:09 pm
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.

Re: Memory Leakage problem with StiReport.

Posted: Tue Feb 11, 2014 7:25 am
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

Re: Memory Leakage problem with StiReport.

Posted: Thu Feb 13, 2014 1:09 pm
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.