Page 1 of 4

memory leaks

Posted: Mon Dec 13, 2010 8:47 pm
by Radek Cerny
we have recently adopted Stimulsoft reports and are now experiencing memory leaks with our application server. We have resorted to using an advanced memory profiler to help diagnose and it finds many faults in Stimulsoft. For example:

Undisposed instances (release resource)
This type has instances that have been garbage collected without being properly disposed. To improve memory/resource utilization, it is recommended that instances of this type are properly disposed. Disposing instances of this type will release resource and suppress finalization.

Stimulsoft.Report!Stimulsoft.Report.StiReportObjectStringConverter.ConvertStringToFont( string )
Stimulsoft.Report!Stimulsoft.Report.StiReportObjectStringConverter.StringToObject( string,Type )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.Deserialize( object,Stream,string )
Stimulsoft.Report!Stimulsoft.Report.SaveLoad.StiXmlReportSLService.Load( StiReport,Stream )
Stimulsoft.Report!Stimulsoft.Report.StiReport.Load( StiReportSLService,Stream )
Stimulsoft.Report!Stimulsoft.Report.StiReport.Load( Stream )
Stimulsoft.Report!Stimulsoft.Report.StiReport.Load( string )

Undisposed instances (memory/resource utilization)
This type has instances that have been garbage collected without being properly disposed. To improve memory/resource utilization, it is recommended that instances of this type are properly disposed. Disposing instances of this type will dispose other instances, suppress finalization, and clear references.

Stimulsoft.Base!Stimulsoft.Base.Drawing.StiImageConverter.BytesToImage( byte[] )
Stimulsoft.Base!Stimulsoft.Base.Drawing.StiImageConverter.StringToImage( string )
Stimulsoft.Report!Stimulsoft.Report.StiReportObjectStringConverter.StringToObject( string,Type )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.DeserializeObject( object,StiPropertyInfoCollection )
Stimulsoft.Base!Stimulsoft.Base.Serializing.StiSerializing.Deserialize( object,Stream,string )
Stimulsoft.Report!Stimulsoft.Report.SaveLoad.StiXmlReportSLService.Load( StiReport,Stream )
Stimulsoft.Report!Stimulsoft.Report.StiReport.Load( StiReportSLService,Stream )
Stimulsoft.Report!Stimulsoft.Report.StiReport.Load( Stream )
Stimulsoft.Report!Stimulsoft.Report.StiReport.Load( string )


I wonder if you might use a similar tool to make sure your code does not have memory leaks.

memory leaks

Posted: Tue Dec 14, 2010 2:41 pm
by Ivan
Hello,

We couldn't reproduce this issue.
Which version of Stimulsoft Reports do you use?
Can you please send us a sample report with data or a simple test application, which reproduce the issue?

Thank you.

memory leaks

Posted: Tue Dec 14, 2010 7:47 pm
by Radek Cerny
As background, we were using Crystal reports which were very unstable, and the functionality of Stimulsoft is great - we are overall very happy with it. But we have noticed that our application server is creeping memory, and we have done many tests locally with advacned memory profilers - if we run our applictions without any reports all is well, but as soon as we use a report there is a small leak.
Here is the code we use:

Code: Select all

            using (StiReport report = new StiReport())
            {
				try
				{
					report.Load(reportFile);
                    report.DataSources.Clear();
                    report.Dictionary.Databases.Clear();
					report.Dictionary.ImportXMLSchema(data);
					report.RegData(data);
                    Stimulsoft.Report.Export.StiPdfExportSettings settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
                    settings.Compressed = true;
                    settings.EmbeddedFonts = false;
					settings.ImageQuality = 0.40f;
					report.Render(false);
					report.ExportDocument(StiExportFormat.Pdf, pdfFileName, settings);
					report.Dictionary.DataStore.Clear();
					data.Clear();
					data.Dispose();
					report.Dispose();
					ok = true;
				}
				catch (FormatException fex)
				{
					host.setMessageToken(1, fex.Message);
					host.setMessageToken(2, reportFile);
					host.addSystemMessage(UserMessage.Severity.Error, reportFile+": Format Exception:" + fex.Message, "RPT_FormatException");
					ok = false;
				}
				catch (Exception ex)
				{
					host.setMessageToken(1, ex.Message);
					host.setMessageToken(2, reportFile);
					host.addSystemMessage(UserMessage.Severity.Error, reportFile+": There is a problem with the data sent to the report:" + ex.Message, "RPT_Exception");
					ok = false;
				}
            }
Running with the ExportDocument line commented still results in the leak.
I have attached a sample report as well.

memory leaks

Posted: Wed Dec 15, 2010 6:03 am
by Ivan
Hello,

We cannot reproduce the issue in our data.
Can you provide data for your report, which reproduces the issue?

Thank you.

memory leaks

Posted: Sat Dec 18, 2010 4:56 pm
by Radek Cerny
Here is a first cut of a self contained application that can demonstrate this problem.
Over time, as you GC.Collect(), the memory will always be reclaimed. If however you run a report, some memory is lost and never reclaimed. As our application servers must be available 24x7, this manifests into a real problem. Over many years we have never had memory leaks as the .NET GC reclaims it.
I will use an advanced memory profiler to report exactly where the leak occurs.
Our senior architect used reflector and said your Finalizer() in the Render() method was very large and was most likely the source of the leak.

memory leaks

Posted: Tue Dec 21, 2010 5:05 am
by Ivan
Hello,

We are working on this issue. We will let you know when the solution is available.

Thank you.

memory leaks

Posted: Fri Dec 24, 2010 4:23 am
by Ivan
Hello,

Please check the following topic on our forum:
http://forum.stimulsoft.com/Default.aspx?g=posts&t=142
I need describe some principles of the functioning the StimulReport.Net.

1. Source code of the report is formed. Forming based on the grounds of meta description of the report
2. This source code is compiled in to assembly
3. Assembly is loaded in to memory
4. Create object of the report from loaded assemblies
5. Report is rendered
6. Report is showed

The loaded assembly occupies place in memories. If ten once produce compiling the report,
that will be ten are once created assembly of the report and loaded in memory. How to correct?
Regrettably .Net Framework does not give the possibility to unload the assembly from memory
(only together with application domain, but this method has much restrictions).

1. Save the report as class and add it to project. In this case compiling occurs
together with project.
2. Save the report as assembly. Before building of the report its necessary to load
from assembly with method StiReport.GetReportFromAssembly.
Also you can try to test the new Interpretation mode of report rendering.
For select this mode, please set the CalculationMode property of the report:

Code: Select all

 report.CalculationMode = StiCalculationMode.Interpretation;
Thank you.

memory leaks

Posted: Tue Dec 28, 2010 9:36 am
by Mpanal
Ivan wrote:
Also you can try to test the new Interpretation mode of report rendering.
For select this mode, please set the CalculationMode property of the report:

Code: Select all

 report.CalculationMode = StiCalculationMode.Interpretation;
Thank you.

I have also problems with memory.

When I try calculation mode Interpretation, I have an error message: "Syntax error near }" I have many "}" on my report. How I can know where is the error?

If calculation mode is Compilation, I have no error. But after 100 - 120 reports, my program hangs for memory consumption.

Thank you

memory leaks

Posted: Tue Dec 28, 2010 12:42 pm
by Ivan
Hello,
Mpanal wrote:When I try calculation mode Interpretation, I have an error message: "Syntax error near }" I have many "}" on my report. How I can know where is the error?
If calculation mode is Compilation, I have no error. But after 100 - 120 reports, my program hangs for memory consumption.
Can you please send us a sample report with data, which reproduce the issue?

Thank you.

memory leaks

Posted: Wed Dec 29, 2010 8:34 am
by Mpanal
Ivan wrote:Hello,
Mpanal wrote:When I try calculation mode Interpretation, I have an error message: "Syntax error near }" I have many "}" on my report. How I can know where is the error?
If calculation mode is Compilation, I have no error. But after 100 - 120 reports, my program hangs for memory consumption.
Can you please send us a sample report with data, which reproduce the issue?

Thank you.

Hello,

I can send you the report, but the data is very difficult because is a very complex report that reads data from a SQLserver on many tables, with different languages, and also, an user data table thats fills on the fly from the program. Also, from the program is filled many variables on the report.

On the Visual Studio, On the form design, If I click on Show report on rigght button menu of the report, I can reproduce the error without data.

Tell me an email for send you the report.

Thank you