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

Memory optimizations for 1,000+ records.

8 Answers 316 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 30 Jul 2019, 03:25 PM

Hi,

I've been tasking with scrubbing our use of Telerik (which is extensive in our app) for memory usage and possible efficiencies, as customers are concerned about high memory usage of our app, and speed.

RadGridView has been flagged as a likely candidate as a "memory hog" for customers that have over 1,000 records loaded at any given time.

 

Here is a snapshot of our implementation:

<telerik:RadGridView AutomationProperties.Name="EventSummaryGrid" x:Name="EventSummaryGrid" Grid.Row="1" Grid.Column="0"
HeaderRowStyle="{DynamicResource THOR_GridViewHeaderRowStyle}"   
local:GridDependencyProperties.ColumnCollection="{Binding ColumnCollection}"  
IsReadOnly="True" EnableColumnVirtualization="True"
CanUserDeleteRows="False" 
CanUserInsertRows="False"
ShowGroupPanel="True"     
AlternationCount="2"
RowIndicatorVisibility="Collapsed"
AutoExpandGroups="True"
MouseDoubleClick="EventSummaryGrid_MouseDoubleClick" 
ItemsSource="{Binding EventSummaryList}" 
AutoGenerateColumns="False"
RowIsExpandedChanged="EventSummaryGrid_RowIsExpandedChanged"
ScrollViewer.HorizontalScrollBarVisibility="Auto" 
ScrollViewer.VerticalScrollBarVisibility="Auto" 
SelectionMode="Extended" ShowColumnSortIndexes="False"
ClipboardCopyMode="All"
FieldFilterEditorCreated="EventSummaryGrid_FieldFilterEditorCreated" 
Loaded="EventSummaryGrid_Loaded"
Sorting="EventSummaryGrid_Sorting">

                <telerik:RadGridView.Resources>
                    <local:SensorTypeConverter x:Key="SensorTypeConverter" />
                    <local:SensorUnitsConverter x:Key="SensorUnitsConverter" />
                    <local:EventTypeConverter x:Key="EventTypeConverter" />
                    <local:StorageTypeConverter x:Key="StorageTypeConverter" />
                    <local:RecordLengthConverter x:Key="RecordLengthConverter" />
                    <local:SampleRateConverter x:Key="SampleRateConverter" />
                    <local:NoOfChannelsConverter x:Key="NoOfChannelsConverter" />
                    <local:NoUsbOfChannelsConverter x:Key="NoUsbOfChannelsConverter" />
                    <local:NumberOfIntervalsConverter x:Key="NumberOfIntervalsConverter" />
                    <local:DateTimeToStringConverter x:Key="DateTimeToStringConverter" />
                    <local:TriggerConverter x:Key="TriggerConverter" />

                </telerik:RadGridView.Resources>

 

- The grid has 60 columns, and filtering and sorting is on for all of them.

Here is an example of a typical column implementation:

 

                    <telerik:GridViewDataColumn x:Name="FileName" DataMemberBinding="{Binding FileName}" 
Header="{x:Static Resources:Resources.EventManagerView_Column_FileName}"
HeaderTextAlignment="Center" TextWrapping="NoWrap" TextTrimming="WordEllipsis" HeaderTextTrimming="WordEllipsis"
CellStyle="{DynamicResource THOR_GridViewCellStyle}"
            IsVisible="True">
                        <telerik:GridViewDataColumn.HeaderCellStyle>
                            <Style TargetType="telerik:GridViewHeaderCell">
                                <Setter Property="ToolTipService.ToolTip" Value="{x:Static Resources:Resources.EventManagerView_Column_FileName}">
                                </Setter>
                            </Style>
                        </telerik:GridViewDataColumn.HeaderCellStyle>
                    </telerik:GridViewDataColumn>

 

..and we use a child template:

 

<telerik:RadGridView.HierarchyChildTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<telerik:Label Margin="30,0,0,0" FontSize="12" FontWeight="Bold" Content="{x:Static Resources:Resources.Saved_Event_Report_Label}"/>
<telerik:RadGridView x:Name="ReportAnnotationsGrid"
GroupRenderMode="Flat"
BorderThickness="0,1,0,1"
AlternationCount="0"
GridLinesVisibility="None"
CanUserFreezeColumns="False"
AutoGenerateColumns="False"
ItemsSource="{Binding Annotations}"
ShowGroupPanel="False"
ShowColumnHeaders="False"
IsReadOnly="True"
MouseDoubleClick="ReportSelection_MouseDoubleClick"
GotFocus="ReportAnnotationsGrid_GotFocus"
SelectionChanged="ReportSelection_SelectionChanged"
CanUserDeleteRows="False" 
CanUserInsertRows="False"
IsFilteringAllowed="False"
FrozenColumnCount="0" 
FrozenColumnsSplitterVisibility="Collapsed"   
RowIndicatorVisibility="Collapsed"
SelectionMode="Single"
Margin="30,0,0,0">

 

...any suggestions on settings to keep the memory usage to a bare minimum would be appreciated !

8 Answers, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 30 Jul 2019, 08:52 PM
Also, would paging help with the memory usage ? - or is it just a visual option to page data rather than look at all of it at once. I assume there's memory gains to be had by not keeping all the records displayed in the grid when it's loaded.
0
Martin Ivanov
Telerik team
answered on 31 Jul 2019, 10:36 AM

Hello Barry,

The RadDataPager should improve the memory because this will process only the rows for the current page. As an alternative solution to paging would be to use a data virtualization. Additionally, you can check the Performance Tips and Tricks article and see if anything from the guidance there would be useful for your setup. Using the lightweight templates for the rows may also decrease the memory footprint.

I hope this helps.

Regards, Martin Ivanov
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
Barry
Top achievements
Rank 1
answered on 31 Jul 2019, 12:55 PM

Thanks for the info !

So paging and the data virtualization both do the same thing ?

0
Barry
Top achievements
Rank 1
answered on 31 Jul 2019, 01:13 PM
I read the article on "Using the lightweight templates for the rows" - it didn't say what exactly they were or where they are. They used a Windows 8 example....but didn't list all the the lightweight templates available, or where they are. If you use any template that comes with Telerik can it be considered to be "light" ?
0
Barry
Top achievements
Rank 1
answered on 31 Jul 2019, 01:20 PM

Ok...I re-read the article. It wounds like if you reference any of the "themes" you will get lightweight style template:

"These styles are added to all built-in themes for Telerik WPF and Silverlight UI components. These styles are defined via the themes of RadGridView and you may include it, via defining simple and pretty basic styles"

- so just use a theme and you get the lightweight style ?

0
Martin Ivanov
Telerik team
answered on 01 Aug 2019, 01:04 PM

Hello Barry,

Paging and data virtualization have the same general idea - they both provide you with a mechanism that loads only a portion of all data. With paging you have several pages of data and only the data for the current page is loaded in RadGridView. On the other hand the VirtualQueryableCollectionView allows you to have a scrollviewer (no paging), but load only the data that should be visible in the current viewport.

The lightweight template are available only with NoXaml and Implicit Styles. You can read more about this in the Lightweight Templates article. To enable those, you will need to define several implicit styles targeting different RadGridView controls (like GridViewRow for example) and base them on the lightweight styles. Here is an example:

<Application.Resources> 
    <ResourceDictionary> 
        <ResourceDictionary.MergedDictionaries> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/System.Windows.xaml"/> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.xaml"/> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.Input.xaml"/> 
            <ResourceDictionary Source="/Telerik.Windows.Themes.Office_Black;component/Themes/Telerik.Windows.Controls.GridView.xaml"/> 
        </ResourceDictionary.MergedDictionaries> 
        <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowCoreStyle}"/> 
        <Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellCoreStyle}"/> 
    </ResourceDictionary> 
</Application.Resources> 
The new styles will override the default ones and the lightweight templates will be applied to the corresponding elements.

Regards, Martin Ivanov
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
Barry
Top achievements
Rank 1
answered on 01 Aug 2019, 02:45 PM

So, we do have custom templates going all over the place, depending on the control in question. If we got rid of all custom templates and used a light-weight template, then we should see some speed gains ?

I attached a sample of of color-scheme. Any suggestions in how to get as close as possible to that using a light-weight template would be appreciated.

0
Martin Ivanov
Telerik team
answered on 05 Aug 2019, 01:20 PM
Hello Barry,

I am afraid that without testing your application I can't tell what will be the gains of using the lightweight templates. What I could suggest you is to test this on your side and share go it goes.

As for the color-scheme, if this is the Office_Blue theme (as it looks) you should get the same look after you apply the corresponding implicit styles (GridViewRowCoreStyle and GridViewCellCoreStyle). If you use custom styles, you can replace them with the ligthweight styles and adjust whatever you need in the extracted style. You can see where to find the all Telerik controls styles (including lightweight styles) in the Editing Control Templates article.

Regards,
Martin Ivanov
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.
Tags
GridView
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or