release of resources
release of resources
Reports.Web 2020.4.1.0
Good morning,
in the web application where we use the stimulsoft reports we have a problem of non-deallocated memory.
The report is displayed through the StiWebViewer object, in a new browser tab.
We would like to be able to intercept the closing of the browser tab to ask the StiWebViewer object to release the resources.
How you do it?
Good morning,
in the web application where we use the stimulsoft reports we have a problem of non-deallocated memory.
The report is displayed through the StiWebViewer object, in a new browser tab.
We would like to be able to intercept the closing of the browser tab to ask the StiWebViewer object to release the resources.
How you do it?
Soft System srl
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: release of resources
Hello,
You can use the static method for clear all data caches:
StiCacheCleaner.Clean(report);
You can use this method to force the current report to be deleted from the server cache:
var cacheGuid = $"{e.RequestParams.Id}_{e.RequestParams.Cache.ClientGuid}";
StiWebViewer.CacheHelper.RemoveReport(cacheGuid);
You can also change the caching method by overriding a special StiCacheHelper class - see documentation for more details:
https://www.stimulsoft.com/en/documenta ... ashing.htm
Thank you.
You can use the static method for clear all data caches:
StiCacheCleaner.Clean(report);
You can use this method to force the current report to be deleted from the server cache:
var cacheGuid = $"{e.RequestParams.Id}_{e.RequestParams.Cache.ClientGuid}";
StiWebViewer.CacheHelper.RemoveReport(cacheGuid);
You can also change the caching method by overriding a special StiCacheHelper class - see documentation for more details:
https://www.stimulsoft.com/en/documenta ... ashing.htm
Thank you.
Re: release of resources
Unfortunately it doesn't seem like a cache problem.
I wish I could destroy the report object when the user closes the browser tab that contains the object.
In other words, when the user closes the browser tab, I would like to run this code:
How do I intercept the closing of the tab?
I wish I could destroy the report object when the user closes the browser tab that contains the object.
In other words, when the user closes the browser tab, I would like to run this code:
Code: Select all
myReport.Dispose();
myReport = null;
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Soft System srl
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: release of resources
Hello,
You can subscribe to a JavaScript event in your browser 'beforeunload', and there to send a request to the server, which will call the method with your code.
Thank you.
You can subscribe to a JavaScript event in your browser 'beforeunload', and there to send a request to the server, which will call the method with your code.
Thank you.
Re: release of resources
In the aspx page there is the StiWebViewer object:
Via Javascript, how do I activate an event of the StiWebViewer1 object?
Code: Select all
<cc2:StiWebViewer ID="StiWebViewer1" runat="server" OnReportDesign="StiWebViewer1_ReportDesign" />
Soft System srl
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: release of resources
Hello,
Which event do you want to activate? If you are referring to an earlier event, the viewer does not support such functionality.
Thank you.
Which event do you want to activate? If you are referring to an earlier event, the viewer does not support such functionality.
Thank you.
Re: release of resources
My goal is: to execute the memory deallocation code when the user closes the browser tab which contains the StiWebViewer object.
Something like:
in aspx file
in aspx.cs file
Unfortunately, the Disposed event does not trigger.
Should I use a different event?
Should I write the JavaScript code differently?
Something like:
in aspx file
Code: Select all
<cc2:StiWebViewer ID="StiWebViewer1" runat="server" OnReportDesign="StiWebViewer1_ReportDesign" OnDisposed="StiWebViewer1_Disposed"/>
<script>
window.beforeunload = function () {
this.jsObject.postAction("Disposed");
};
</script>
Code: Select all
protected void StiWebViewer1_Disposed(object sender, EventArgs e)
{
using (StreamWriter file =
new StreamWriter(sLog, true))
{
file.WriteLine("Unload");
}
StiReport myReport = StiWebViewer1.Report;
myReport.Dispose();
myReport = null;
//Forza il garbage collector a liberare la memoria allocata dall'assembly e dai dati
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
}
Unfortunately, the Disposed event does not trigger.
Should I use a different event?
Should I write the JavaScript code differently?
Soft System srl
-
- Posts: 6245
- Joined: Tue Mar 20, 2018 5:34 am
Re: release of resources
Hello,
Unfortunately, the viewer does not support such functionality.
Thank you.
Unfortunately, the viewer does not support such functionality.
Thank you.
Re: release of resources
You are welcome!