Page 4 of 4

memory leaks

Posted: Mon Dec 05, 2011 8:08 am
by ikirck
It is a Stimulsoft.Report.Render.StiPreviewControl.

I don't have the time to do a sample project right now, so I hope that the code examples I provided are sufficient to get to the roots of this issue.

Thank you.

memory leaks

Posted: Tue Dec 06, 2011 3:49 am
by HighAley
Hello.

Maybe in your case it will be useful to use Application Domains. Here is our methods for creation and unloading:

Code: Select all

		#region AppDomain
		internal AppDomain reportDomain = null;

		public StiReport CreateReportInNewAppDomain()
		{
			AppDomainSetup appDomainSetup = new AppDomainSetup();
			appDomainSetup.ShadowCopyFiles = "false";
			appDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
			AppDomain appDomain = AppDomain.CreateDomain(StiGuidUtils.NewGuid(), AppDomain.CurrentDomain.Evidence, appDomainSetup);
			
			StiReport report = appDomain.CreateInstanceAndUnwrap(this.GetType().Assembly.FullName, this.GetType().FullName)
				as StiReport;

			reportDomain = appDomain;

			report.LoadFromString(this.SaveToString());
            
			foreach (StiData data in this.DataStore)
			{
				report.RegData(data.Name, data.Data);
				report.DataStore[report.DataStore.Count - 1].ViewData = data.ViewData;
			}

			return report;
		}


		public void UnloadReportAppDomain()
		{
			if (reportDomain != null)
			{
				AppDomain.Unload(reportDomain);
				reportDomain = null;
			}
		}
		#endregion
You can change our code for your needs. But there is a loss of performance when using application domains.

Thank you.