Memory Leaks in DataGrid?

Hi 

I have an application that is running on .NET MAUI Desktop.  When i load the the data into the data grid and then want to reset the data by updating the ItemSource, the memory just seems to keep climbing.

I have tried forcing garbage collection and this does release some but the majority of the memory is retained.

I have even tried clearing the datagrid in various ways as below prior to loading it with new data but still doesnt work.  

 opsDataGrid.ItemsSource = null;

 opsDataGrid.ClearLogicalChildren();

 opsDataGrid.Resources.Clear();

I have attached the full function below, if anyone can help or has similar problems please let me know.

Thanks


public void SetOpsDataGrid()

{


    opsDataGrid.ItemsSource = null;
    opsDataGrid.ClearLogicalChildren();
    opsDataGrid.Resources.Clear();


    // Create the filteredOps list once and reuse it
    var filteredOps = memory.Operations
        .Where(x => !x.OpCompleted &&
                    (string.IsNullOrEmpty(filterJobNo) || x.Job.JobNo.Equals(filterJobNo, StringComparison.OrdinalIgnoreCase)) &&
                    (string.IsNullOrEmpty(findJobNo) || x.Job.JobNo.Equals(findJobNo, StringComparison.OrdinalIgnoreCase)) &&
                    (string.IsNullOrEmpty(filterPartNo) || x.Job.PartNo.Equals(filterPartNo, StringComparison.OrdinalIgnoreCase)) &&
                    (string.IsNullOrEmpty(filterSalesNo) || x.Job.SalesNo.Equals(filterSalesNo, StringComparison.OrdinalIgnoreCase)))
        .OrderBy(x => x.Priority)
        .ToList();


    // If no filtered results and filters are set, use all operations
    if (!filteredOps.Any() &&
        (!string.IsNullOrEmpty(filterJobNo) || !string.IsNullOrEmpty(filterPartNo) || !string.IsNullOrEmpty(filterSalesNo) || !string.IsNullOrEmpty(findJobNo)))
    {
        filteredOps = memory.Operations
            .Where(x => !x.OpCompleted)
            .ToList();
    }


    // Set the ItemsSource for the data grid
    opsDataGrid.ItemsSource = filteredOps
        .OrderBy(x => x.Job.JobNo)
        .ThenBy(x => x.ScheduledStartDate)
        .ToList();


    filteredOps.Clear();
    filteredOps = null;
}





9 Replies

RO Robert May 23, 2024 08:56 AM UTC

Can someone from SF reply to this please and confirm if there are known memory leaks or am i doing something wrong?



SD Sethupathy Devarajan Syncfusion Team May 24, 2024 02:43 PM UTC

Hi Robert,

We have checked your query at our end, and we are able to replicate that issue at our end. We have considered this as a  bug and logged a bug report regarding this in our feedback portal. We will fix the reported issue and include the changes in our upcoming weekly patch release, which is expected to be rolled out on June 18, 2024. We will let you know once released, and we appreciate your patience until then.

 

FeedBack Link - 58131


Regards,

Sethupathy Devarajan




DM Devashri Mahindrakar June 17, 2024 10:47 AM UTC

We are also facing this exact issue. Could you please confirm if a fix would be rolled out tomorrow, 18th June 2024?


Thanks,

Devashri



NY Nirmalkumar Yuvaraj Syncfusion Team June 18, 2024 08:34 AM UTC

Hi Devashri


As we had our main release last week, the weekly release has been postponed to tomorrow, June 19, 2024. The fix will be incorporated into our weekly release scheduled for tomorrow. We appreciate your patience and understanding in the meantime.


Regards,

Nirmalkumar.



DM Devashri Mahindrakar June 19, 2024 08:19 AM UTC

Hi Team, Is this fix scheduled for today's release?




SD Sethupathy Devarajan Syncfusion Team June 19, 2024 02:10 PM UTC

Hi Robert and Devashri,,


We are glad to inform you that the reported issue regarding Memory Increases When Switching Item Source” has been included in our weekly NuGet release for the mentioned issue. Please update the Syncfusion.Maui.DataGrid  package to version 26.1.38.


https://www.nuget.org/packages/Syncfusion.Maui.DataGrid


Root Cause:

Wire the event before calling OnItemSourceChanged in the RowGenerator, which cause the issue.


We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you require any further assistance.


Regards,

Sethupathy D.



DM Devashri Mahindrakar June 21, 2024 12:04 PM UTC

Hi Sethupathy,

We upgraded the the SfDataGrid version in our application and observed memory leaks while switching to different pages having datagrids. As you mentioned for tab view and grid control combination you will release fix in July, so we created a POC with multiple grids on multiple pages rather than tabs, but still issue persist and grid memory keeps on increasing.

Please advice how this can be handled to avoid memory leaks with latest package (26.1.38). I have attached a sample project for your reference, the memory keeps increasing when we switch between pages on button click.  


Thanks, 

Devashri


Attachment: MemoryDatagrid_95c4cbf8.zip



SD Sethupathy Devarajan Syncfusion Team June 24, 2024 05:54 AM UTC

Hi Devashri,


In our previous response, we stated that we had fixed the reported issue regarding "Memory increases when switching the item source." Based on your latest response, it is clear that you observed a memory leak while switching to different pages, which we had not mentioned. Regarding the memory leak with the tab view and grid combination, its fix will be included in our 2024 Volume 2 SP release.


Regards,

Sethupathy Devarajan.



AP Abinesh Palanisamy Syncfusion Team July 25, 2024 12:39 PM UTC

Hi Devashri,

 

Since you have created a separate ticket under your account in our ticketing system and have had several follow-ups categorizing the issue as a framework, we kindly ask you to track that ticket for future updates.

 

Framework Issue Link:  https://github.com/dotnet/maui/issues/23680

 

Regards,

Abinesh P



Loader.
Up arrow icon