We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to reclaim Memory usage?

Thread ID:

Created:

Updated:

Platform:

Replies:

130043 Apr 18,2017 05:48 AM Dec 18,2017 07:46 AM Xamarin.Forms 4
loading
Tags: SfDataGrid
Emil
Asked On April 18, 2017 05:48 AM

Hi,

Do we have to set bindingcontext=null or sfdatagrid=null on OnDisappearing event in order to reclaim memory usage  or is it usually automaticly handled? I see something in your samples, you do it as well. 

   protected override void OnDisappearing()
        {
           BindingContext = null;
            Content = null;
            base.OnDisappearing();
            GC.Collect();
        }

Pavithra  Sivakumar [Syncfusion]
Replied On April 19, 2017 10:04 AM

Hi Emil, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. The disposing of mono and native objects are not correctly happening in all the scenarios in Xamarin.Forms. Hence we have manually disposed our controls in the OnDisappearing() override to reclaim the memory efficiently. Hence we recommend you to dispose our controls when the page containing the controls are disposed of.  
 
Regards, 
Pavithra S 
 


Shawn Castrianni
Replied On July 19, 2017 10:38 AM

How do we do that correctly?  OnDisappearing does NOT mean the page is being disposed, it just means it is no longer the top page.  In other words if I have a mainpage on the screen and then I push a detail page on top, it will call the OnDisappearing for the mainPage and the OnAppearing for the detailpage.  In this very common scenario, I would not want to dispose of anything on the mainpage because as soon as the user clicks Back, I will be seeing the mainpage again so I don't want to dispose of it.

Perhaps you are saying for the OnAppearing event to always create the SyncFusion datagrid and the OnDisappearing event to always dispose of the syncfusion data grid.  I suppose that will work, but would be a lot of unnecessary destruction and creation of datagrid as pages are pushed and popped on the Navigation stack.


Dave Friedel
Replied On December 16, 2017 07:54 PM

I agree. Syncfusion needs to resolve this 

Ashok N [Syncfusion]
Replied On December 18, 2017 07:46 AM

Hi Dave, 
 
Thanks for your update. Now it is not mandatory to dispose the custom controls in the OnDisappearing override and create the instances in the OnAppearing override method manually. Earlier there were issues in the framework when navigating between the pages, and hence we had informed to dispose grid in OnDisappearing as a workaround. But now, the disposing of objects is done properly in the Framework itself when the GC is collected and hence the manual disposing of the view will no longer be needed unless you need to handle the memory more efficiently to free up the spaces utilized by your application.  
 
Please let us know if you require any further clarifications.  
 
Regards, 
Ashok 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;