memory leaks

Stimulsoft Reports.NET discussion
ikirck
Posts: 23
Joined: Fri Aug 25, 2006 4:25 am

memory leaks

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

memory leaks

Post 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.
Post Reply