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

GridView performance and memory issues

2 Answers 1105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ignacio
Top achievements
Rank 1
Ignacio asked on 12 Mar 2021, 08:07 PM

1.- Issue:
I have a RadGridView consisting of one master template and a child template. I query my database, build a dataset and I assign it to the RadGridView datasource.

It works just fine with few records but when I pull a considerable amount of data it takes forever to render, specially if I want my rows to be expanded from the beginning.

For Each row As GridViewRowInfo In template.Rows
     row.IsExpanded = True
Next

Is there any way to improve the render time of the RadGridView ? The query and code take around 3 seconds to run, but when I go row by row expanding all of them it just takes like 2 minutes. I am attaching what it looks like when it finished loading. The 400 row hast more than 8000 records in the child template. I know its big data, but is there any way to improve this ?

2.- Issue
As soon as the RadGridView finishes loading the data mentioned above, if I close the screen the resources are not freed at all. I tried calling RadGridView1.Dispose() but it takes more than 10 seconds to just run the dispose command. Is this a known issue that the RadGridView eats a lot of memory and can't free it by itself ?

I am running Telerik for WinForms 2020.2.616.40

Thanks for any information provided.

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Mar 2021, 08:07 AM

Hello, Ignacio, 

Straight to your questions:

1. When you set the IsExpanded property to true for a row, note that it makes a refresh operation in the grid. Hence, the more rows are expanded, the more refresh operations will be performed. The possible solution that I can suggest for this case is to use BeginUpdate/EndUpdate block while the rows are set as expanded. Thus, only one refresh operation will be performed at the end: 

            this.radGridView1.BeginUpdate();
            foreach (GridViewRowInfo r in this.radGridView1.Rows)
            {
                r.IsExpanded = true;
            }
            this.radGridView1.EndUpdate();

Additional tips for improving the performance are setting the UseScrollbarsInHierarchy property to true, the TableElement.RowScroller.ScrollMode property to ItemScrollerScrollModes.Deferred. Deferred scrolling updates the view only when the scrollbar thumb is released. A tooltip helps indicating the position to which the view will be scrolled to.

2. We haven't had similar memory concerns about RadGridView form other customers. 

I would like to let you know that our controls provide rich UI capabilities and theming mechanism which inevitably increases the memory usage. Furthermore, our components are built from the Telerik Presentation Framework which is built on top of the .NET Framework which once again, inevitably increases memory usage compared to other controls, such as the standard controls which simply wrap native objects.  Unless a certain control has a memory leak, it is eventually being disposed. Calling GC.Collect will not dispose the objects immediately, they will simply be marked for disposal and the next time the Garbage Collector passes by it will decide whether they are suitable for actual disposal. This is due to the non-deterministic behavior of the Garbage Collector. Our objects are mostly from Generation 3, which means that they will be disposed at a later state (more about garbage collection).

The memory leak might be caused by the fact that you are showing a new Form instance every time with the ShowDialog method. A quote from MSDN says: "Unlike modeless forms, the Close method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the DialogResult property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is not closed, you must call the Dispose method of the form when the form is no longer needed by your application.

If you are still experiencing any further problems related to memory consumption, I would kindly ask you to submit a support ticket from your Telerik account where you can provide a sample project demonstrating the problem. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. Thank you in advance.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Ignacio
Top achievements
Rank 1
answered on 17 Mar 2021, 03:27 PM
Thank you very much Dess. The Deferred Scroll Mode made a huge impact on the performance and it's working great now. And now when I close the screen the resources are being freed as expected.
Tags
GridView
Asked by
Ignacio
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Ignacio
Top achievements
Rank 1
Share this question
or