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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Memory lead with SfDataGrid?

Thread ID:





128735 Feb 8,2017 03:21 PM UTC Feb 10,2017 12:08 PM UTC UWP 3
Tags: SfDataGrid
Pierre-Christophe DUS
Asked On February 8, 2017 03:21 PM UTC


I've developed an UWP app where the "Home" page is based on the SfDataGrid. This app allows users to consult and edit forms that are saved locally then to sync them.
But I can see that each time that I navigate from the "Home" page to the "Details" page and come back to the "Home" page, the memory is not released and increases.

I've done some snapshots with the Performance Profiler:
  1. start of the app : "Home" page
  2. navigate to "Details" page
  3. back to "Home" page
  4. navigate to "Details" page
  5. back to "Home" page
Here is the result for "Heap" memory:
Here is the result for "Managed Heap" memory:
Managed Heap
We can see that the bigger  difference for the "Heap" memory occurs in the last snapshot: +13.46 MB
When I look the details, there a big number of references to the Syncfusion.SfGrid:
Head - snap 5

For the "Managed Heap" memory, it's always in the last snapshot that we get the bigger increase: +1.12 MB
When I look the details, there are 2 references to Syncfusion (sfDrid/Data) that increase more than 600 000 Bytes:
Managed Head - snap5

Is it normal? Would you have any explanation?


Jai Ganesh S [Syncfusion]
Replied On February 9, 2017 01:15 PM UTC

Hi Pierre, 
We have analyzed your query. In your application whether you are setting the SfDataGrid.Dispose() while navigate to Details page from Home page? if you not setting it in your application then could you please set the Dispose method while navigating the page.  
If still you are facing the memory leak issue after setting the Dispose(), then could you please share your application or provide the simple sample to reproduce the issue to us? It will be helpful for us to analyze further. 
Jai Ganesh S 

Pierre-Christophe DUS
Replied On February 9, 2017 02:02 PM UTC

I had not yet setted the SfGrid.Dispose() when navigating from Home page to Details page. So I've tested and it seems to work.

I've implemented it in OnNavigatedFrom() method like this:
protected override void OnNavigatedFrom(NavigationEventArgs e)
// Dispose resources
this.Loaded -= FilteringLoaded;
this.sfDataGrid.CurrentCellRequestNavigate -= OnSfDataGridCurrentCellRequestNavigate;
this.sfDataGrid.ItemsSource = null;

NavigationCacheMode = NavigationCacheMode.Disabled;
Would you have recommandations on the use of Dispose with a ViewModel first approach?

Jai Ganesh S [Syncfusion]
Replied On February 10, 2017 12:08 PM UTC

Hi Pierre,  
The OnNavigateFrom is an override method and we cannot use it from view model. However, you can call the Dispose() using mvvm pattern while navigate to other page by wiring behavior of the page and call Dispose() inside the page Unloaded event like below, 
            <local:Behaviour /> 
public class Behaviour : DependencyObject, IBehavior 
    Page page; 
    public DependencyObject AssociatedObject 
            return page; 
    public void Attach(DependencyObject associatedObject) 
        page = associatedObject as Page; 
        page.Unloaded += Page_Unloaded; 
    private void Page_Unloaded(object sender, RoutedEventArgs e) 
        var grid = (page.Content as Grid).Children[0] as SfDataGrid; 
        grid.ItemsSource = null; 
    public void Detach() 
        page.Unloaded -= Page_Unloaded; 
Jai Ganesh S 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon