Memory Leak

Stimulsoft Reports.NET discussion
Post Reply
FT1
Posts: 11
Joined: Sun Mar 03, 2019 1:44 am

Memory Leak

Post by FT1 »

Hello, we are having a potential Memory Leak Issue with stimulsoft rendering on Windows Server
This is our code:

Code: Select all

string DS = Convert.FromBase64String("some long base64 here...");
Assembly DLL = Assembly.Load(Convert.FromBase64String("some long base64 here...."));
using (StiReport report = StiReport.GetReportFromAssembly(DLL))
{
	report.Dictionary.Resources["DS"].Content = DS;
	report.Render(false);
	using (MemoryStream Output = new MemoryStream())
	{
		var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
		settings.UserAccessPrivileges = StiUserAccessPrivileges.PrintDocument;
		settings.ImageQuality = 0.8F;
		settings.ImageResolution = 300;
		report.ExportDocument(StiExportFormat.Pdf, Output, settings);
		DLL = null;
		report.Dispose();
		string O = Convert.ToBase64String(Output.ToArray());
		Output.Dispose();
		return O;
	}
}
The Assembly "DLL" is a variable object, it can repeat or change on each render
The "DS" string is a XML Data file, also variable on each render
The RAM keeps growing about 200MB every 1000 render cicles until server RAM is full and the application crashes.
We have been very careful to dispose objects and implement "using" statements, but the RAM is out of control
Any thoughts?.. are we doing something wrong here?

Thanks
Francesco
FT1
Posts: 11
Joined: Sun Mar 03, 2019 1:44 am

Re: Memory Leak

Post by FT1 »

Hello
To everyone reading about this:
We did a test with a static assembly pool and the memory went completely stable after a 10K render test run
So the problem is here:
Assembly DLL = Assembly.Load(Convert.FromBase64String("some long base64 here...."));

We are figuring out how to Load the Assembly on a separate domain so we can Unload the domain without unloading the whole application
I'll post here the solution when we reach it.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Memory Leak

Post by HighAley »

Hello,

You could find how to load an assembly into an Application Domain on MS doc.
https://docs.microsoft.com/en-us/dotnet ... ion-domain

Also, please, read the next message:
viewtopic.php?p=374#p374

Thank you.
Post Reply