This is a migrated thread and some comments may be shown as answers.

RadGridView memory leak issue

9 Answers 769 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 05 Dec 2018, 11:01 AM

Hi Team,

We were previously using the 2017.2.614.45 version of the Telerik controls and were facing memory leak issues with RadGridView. We have hence upgraded to 2018.3.1016.45 version of the controls but still are facing the same memory leak issues. 

We use RadPane which is placed in a RadPaneGroup; the pane in turn contains the RadGridView. We have handled the closed event of the RadPaneGroup wherein we do our cleanup operations(unsubscribing RadGridView events, setting DataContext as null). As stated in one of the forum posts, we also do the cleanup operations advised which is given at the end. 

Please also find the memory profile report of our application when we closed the RadPane. 

Kindly advise.

 

Regards,

Swapnil Ramteke

private void radDocking_Close(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
        {
            try
            {
                if (e.Panes.Count() == 1)
                {
                    var pane = e.Panes.ElementAt(0);
                    if (pane is IDispose)
                    {
                        (pane as IDispose).Dispose();
                    }
 
                    pane.Content = null;
                    pane.Header = null;
                    pane.DataContext = null;
                    pane.RemoveFromParent();
                    pane = null;
                    // Wait for 5 seconds before garbage collection
                    System.Threading.Tasks.Task.Delay(5000).ContinueWith(antecedent =>
                        {
                            GC.WaitForPendingFinalizers();
                            GC.Collect();
                        });
                }
            }
            catch (Exception)
            {
 
            }
        }

9 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 10 Dec 2018, 10:08 AM
Hello Swapnil,

Thank you for the provided image and code snippet. I will try to reproduce this memory leak on my side using the provided information and let you know the outcome. 

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Swapnil
Top achievements
Rank 1
answered on 13 Dec 2018, 07:25 AM

Hello  Dinko,

Any updates?

Regards,

Swapnil

0
Dinko | Tech Support Engineer
Telerik team
answered on 13 Dec 2018, 12:39 PM
Hello Swapnil,

Thank you for your patience.

I have tried various scenario but wasn't able to reproduce this memory leak. I think I am missing how you have set up the RadDocking and RadGridView controls. I am attaching the sample project which I used to test your case. May I ask you to take a look at this project and let me know what I am missing.

For a memory profiler, I have used JustTrace.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Swapnil
Top achievements
Rank 1
answered on 13 Dec 2018, 02:10 PM

Hello Dinko,

We use a custom DockingPanesFactory the code for which is placed below:

public class ShellDockingPanesFactory : DockingPanesFactory
   {       
       protected override void AddPane(RadDocking radDocking, RadPane pane)
       {
           var paneModel = pane as IPaneModel;
           if (paneModel != null && !(pane is RadDocumentPane))
           {
               RadPaneGroup group = null;
               switch (paneModel.Position)
               {
                   case DockState.DockedRight:
                       group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "rightGroup") as RadPaneGroup;
                       if (group != null)
                       {
                           group.Items.Add(pane);
                       }
                       return;
                   case DockState.DockedBottom:
                       group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "bottomGroup") as RadPaneGroup;
                       if (group != null)
                       {
                           group.Items.Add(pane);
                       }
                       return;
                   case DockState.DockedLeft:
                       group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "leftGroup") as RadPaneGroup;
                       if (group != null)
                       {
                           group.Items.Add(pane);
                       }
                       return;
                   case DockState.DockedTop:
                       group = radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name == "centerGroup") as RadPaneGroup;
                       if (group != null)
                       {
                           group.Items.Add(pane);
                       }
                       return;
                   case DockState.FloatingDockable:
                       var fdSplitContainer = radDocking.GeneratedItemsFactory.CreateSplitContainer();
                       group = radDocking.GeneratedItemsFactory.CreatePaneGroup();
                       fdSplitContainer.Items.Add(group);
                       group.Items.Add(pane);
                       radDocking.Items.Add(fdSplitContainer);
                       pane.MakeFloatingDockable();
                       return;
                   case DockState.FloatingOnly:
                       var foSplitContainer = radDocking.GeneratedItemsFactory.CreateSplitContainer();
                       group = radDocking.GeneratedItemsFactory.CreatePaneGroup();
                       foSplitContainer.Items.Add(group);
                       group.Items.Add(pane);
                       radDocking.Items.Add(foSplitContainer);
                       pane.MakeFloatingOnly();
                       return;
                   default:
                       return;
               }
           }
 
           base.AddPane(radDocking, pane);
       }
   }

 

We use PRISM in our main window, and then views are injected dynamically. The following is the code of the RadDocking in our MainWindow:

<telerik:RadDocking x:Name="radDocking"
                            Visibility="{Binding IsLoggedIn,Converter={StaticResource BoolVisibilityConverter}}"
                            Grid.Row="1"
                            Background="#FFEEEEF2"
                            BorderThickness="0"
                            prism:RegionManager.RegionName="DockRegion"
                            prism:RegionManager.RegionContext="{Binding ViewReference}"                           
                            PreviewClose="radDocking_PreviewClose"                           
                            Close="radDocking_Close">
            <telerik:RadDocking.DockingPanesFactory>
                <local:ShellDockingPanesFactory />
            </telerik:RadDocking.DockingPanesFactory>
            <telerik:RadDocking.DocumentHost>
                <telerik:RadSplitContainer>
                    <telerik:RadPaneGroup x:Name="centerGroup" telerik:RadDocking.SerializationTag="centerGroup" ScrollViewer.HorizontalScrollBarVisibility="Auto" DropDownDisplayMode="WhenNeeded"/>
                </telerik:RadSplitContainer>
            </telerik:RadDocking.DocumentHost>
            <telerik:RadSplitContainer InitialPosition="DockedLeft" >
                <telerik:RadPaneGroup x:Name="leftGroup" telerik:RadDocking.SerializationTag="leftGroup"/>
            </telerik:RadSplitContainer>
            <telerik:RadSplitContainer InitialPosition="DockedRight" >
                <telerik:RadPaneGroup x:Name="rightGroup" telerik:RadDocking.SerializationTag="rightGroup"/>
            </telerik:RadSplitContainer>
            <telerik:RadSplitContainer InitialPosition="DockedBottom" >
                <telerik:RadPaneGroup x:Name="bottomGroup" telerik:RadDocking.SerializationTag="bottomGroup"/>
            </telerik:RadSplitContainer>
            <telerik:RadSplitContainer InitialPosition="DockedTop" x:Name="topContainer">
                <telerik:RadPaneGroup x:Name="topGroup" telerik:RadDocking.SerializationTag="topGroup"/>
            </telerik:RadSplitContainer>
        </telerik:RadDocking>

 

We have custom RadPanes which are injected into the same. 

Please let me know if this information suffices or any additional information is required.

 

Regards,

Swapnil

 

 

0
Dinko | Tech Support Engineer
Telerik team
answered on 18 Dec 2018, 11:53 AM
Hi Swapnil,

Thank you for the provided code snippet. Still, I wasn't able to reproduce this memory leak. I am not exactly sure how you are adding RadGridView control inside the RadPane. Could it be possible to modify the project attached in my previous reply to demonstrate this behavior?

In addition, after a discussion, a possible memory leak could appear after the closing of the RadPane when the x:Name=""  of the RadGridView is specified. Basically, declaring such name in the XAML causes that instance to be referred by the UserControl in which it is declared. Because of this static reference that the MainPage holds, the RadGridView cannot be garbage collected and is left in the memory. Can you double check on your side if such Name is set to the RadGridView and remove it?

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Pawel
Top achievements
Rank 1
answered on 21 Dec 2018, 09:41 AM

Could you provide some memory data. 

Provide two memory dumps

1. start application

2. make dump

3. Preform operations which will cause memory leak 

4. make dupm

 

How to make dump open task manager right click on the application "create dump file"

0
Swapnil
Top achievements
Rank 1
answered on 24 Dec 2018, 08:22 AM
Test
0
Swapnil
Top achievements
Rank 1
answered on 26 Dec 2018, 08:06 AM

Hi,
I am not able to upload the files as the size is very large. Is there an alternate link where i can upload the same?

Regards,

Swapnil

Patrick
Top achievements
Rank 1
commented on 27 Dec 2022, 06:19 PM

Hello,

 

I am experiencing the same problem.

Did you guys ever happen to get to the bottom of it? 

 

Regards,

Patrick

0
Pawel
Top achievements
Rank 1
answered on 26 Dec 2018, 11:17 AM
Hi, google drive and share link.
Tags
GridView
Asked by
Swapnil
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Swapnil
Top achievements
Rank 1
Pawel
Top achievements
Rank 1
Share this question
or