Page 1 of 1

Memory issue

Posted: Fri Mar 08, 2013 2:11 pm
by mikry
Hello,

I have a problem with release memory. In my small example is only create of StiReport object and calling Render function. Then i try release whole object from memory. But after that is still some alocated memory. If I run this function 1000x allocated memory still increases!

What I must do for complete memory free?

Thanks Michal

Re: Memory issue

Posted: Sat Mar 09, 2013 10:03 am
by Jan

Re: Memory issue

Posted: Mon Mar 11, 2013 6:14 am
by mikry
Hello,

do You tried this solution ever? This solution has two problems.

1) alocated too match memory like siple "new" sintax, look at attachment
StimulSoftMemory
StimulSoftMemory
StimulSoftMemory.jpg (100.09 KiB) Viewed 2836 times
.

In my simple exemple before You can just add new method

string compiledReportFile = "report_tmp.mrt";
private void GenerateSec(string template)
{
StiReport report = null;

if (File.Exists(compiledReportFile))
{
report = StiReport.GetReportFromAssembly(compiledReportFile, true);
}
else
{
report = new StiReport();
report.Load(template);
report.Compile(compiledReportFile);
}
report.Render(false);

report.RenderedPages.Clear();
report.Dispose();
GC.Collect();
}

2) second probel of this solution is worse. This solution has problem with multithreading. If we run generation very fast in few threads, then was unexpectedly raise errors with some problem in template. Not for all, but always for couple documents. We change sintax from "GetReportFromAssembly" to simple "new" and problem disappeared.

Michal

Re: Memory issue

Posted: Mon Mar 11, 2013 7:20 am
by mikry
Method "GetReportFromAssembly" has parameter "lockFile". If this parameter is true it, then the very big memory space is alocated and mostly released after time, but still grows. This is still bad. If this parameter is not set (false), then memory is not released never.

If I want used this parameter "lockFile" i must save complited report to the disk. That is imposible in my solution.

I'm afraid, that parameter make from multithread app single thred app.

Michal

Re: Memory issue

Posted: Mon Mar 11, 2013 1:28 pm
by HighAley
Hello.

There is another solution of your issue. You could use the Interpretation mode of the report.
Please, let us know if you will have any problem with it.

Thank you.

Re: Memory issue

Posted: Tue Mar 12, 2013 7:21 am
by mikry
Hello, in Your last oficial version "Stimulsoft Reports.Net 2012.3" is the Interpretation mode marked as "Beta". I can't risk some other error.

Why You can't release all alocated sources after Dispose() object? Where is problem? I don't understand. This is standard behavior of all .NET objects.

What is diferent in paramater "lockFile"? Why the version of function GetReportFromAssembly(Stream assemblyStream) is diferent then GetReportFromAssembly(string assemblyFile, true) ?

Michal

Re: Memory issue

Posted: Tue Mar 12, 2013 2:18 pm
by HighAley
Hello.
mikry wrote:Hello, in Your last oficial version "Stimulsoft Reports.Net 2012.3" is the Interpretation mode marked as "Beta". I can't risk some other error.
This mode needs very much time to become final.
mikry wrote:Why You can't release all alocated sources after Dispose() object? Where is problem? I don't understand. This is standard behavior of all .NET objects.
The report is compiled to assemby. The assembly is loaded to memory and the report instance is created there.
Then please read next article:
http://stimulsoft.helpserve.com/index.p ... ticleid=24

The fact is that .NET Framework cannot unload an assembly from memory. It can be unloaded only together with the application domain, which loaded it. If the assembly (the report) is loaded with a basic application domain, then it is impossible to unload it (only if you close the application).
mikry wrote:What is diferent in paramater "lockFile"? Why the version of function GetReportFromAssembly(Stream assemblyStream) is diferent then GetReportFromAssembly(string assemblyFile, true) ?
Save the report as assembly. Before building of the report its necessary to load from assembly with method StiReport.GetReportFromAssembly.

Method has two variants of the work:
1. StiReport report = StiReport.GetReportFromAssembly("myreport.dll");

Report will is loaded in memory exactly so much once how much will is caused this method,
but at file of the assembly of the report will not be locked.

2. StiReport report = StiReport.GetReportFromAssembly("myreport.dll", true);

Report will is loaded in memory only once even though cause the method over and over again.
At file of the assembly will be locked before closing of application (blocking leaves only after
closing of application). Use of this method does not cause the memory leaks since assembly
of the report is loaded in memory only once.

You can read about it on our forum: http://forum.stimulsoft.com/viewtopic.php?&t=131

Thank you.