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

Memory leaks with IsContentPreserved and remove from MVVM-binded ItemSource

4 Answers 262 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Aleksey
Top achievements
Rank 1
Aleksey asked on 14 May 2014, 06:54 AM
Have TabControl
<telerik:RadTabControl Name="TabControl" IsContentPreserved="True"  ItemsSource="{Binding Workspaces}" SelectedItem="{Binding CurrentWorkspace, Mode=TwoWay}">
ItemsSource in binding using MVVM to ObservableCollection<ViewBase>.
Program dynamically add tabs in it and remove it. When tab is removed, memory is leak, because there is a link to ViewBase class from some dictionary. There is also TabItem in memory but not in TabControl.Items.
If IsContentPreserved="False" there is no leak.
If defined empty ContentTemplate for TabControl there is no memory leak.
<telerik:RadTabControl.ContentTemplate>
    <DataTemplate>
    </DataTemplate>
</telerik:RadTabControl.ContentTemplate>

4 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 15 May 2014, 10:46 AM
Hello Aleksey,

We have tried to reproduce the memory leak that you have reported, but with no success. We used JustTrace to profile the application and it did not report any remaining RadTabItems after the test. I attached the project we used for the test, if you cant reproduce the issue could you please modify the project and send it back to us. Also I would like to ask you to tell us the profiler tool you used.

Looking forward to hearing from you.

Regards,
Kiril Vandov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Aleksey
Top achievements
Rank 1
answered on 16 May 2014, 07:48 AM
Thanks for answer!
Cannot reproduce it with small example. Maybe it is depends of content.
<telerik:RadGridView
                     Grid.Row="1"
                     Style="{StaticResource RadGridViewStyle}"
                     ItemsSource="{Binding Items}"
                     SelectedItem="{Binding CurrentItem, Mode=TwoWay}"
                     Name="MyName">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Width="200" Header="IsNotInclude" DataMemberBinding="{Binding IsNotInclude}" MinWidth="100" CellStyle="{StaticResource centerCellStyle}"/>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

RadGridViewStyle it is default style for grid defined in app.xaml. centerCellStyle is default style for bool columns.
<Style x:Key="RadGridViewStyle" TargetType="telerik:RadGridView">
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Visible"/>
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Visible"/>
    <Setter Property="ShowGroupPanel" Value="False"/>
    <Setter Property="SelectionMode" Value="Single"/>
    <Setter Property="AutoGenerateColumns" Value="False"/>
    <Setter Property="IsReadOnly" Value="True"/>
    <Setter Property="RowIndicatorVisibility" Value="Collapsed"/>
</Style>
 
<Style TargetType="telerik:GridViewCell" x:Key="centerCellStyle">
    <Setter Property="VerticalContentAlignment"  Value="Center" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>

PS. I'm using Telerik 2012.3.1017.1050 because of this http://www.telerik.com/forums/styleselector-null-return-bug and may be other new features (not comletly tested).
0
Aleksey
Top achievements
Rank 1
answered on 17 May 2014, 09:13 AM
Work about this memory leaks found three memory leaks problems:
1) Last screenshot probably is bug ""Memory leak when an application resource is applied to a column dependency property" due to some problems when RadGridView is hosted in RadTabControl" that was fixed in 2013Q1. Not tested because i'm still at 2012Q3.
2) I'm used RelayCommand with potential memory leak (RefreshCanExecute "strong" event). Google "RelayCommand memory leak MVVM"
3) Using MyMultiSelectBehavior http://www.telerik.com/forums/multiselect-binding-in-radgridview in TabControl cause memory leak too. Replacing CollectionChangedHandler to weak CollectionChangedHandler with WeakReference fix it.
0
Kiril Vandov
Telerik team
answered on 20 May 2014, 10:15 AM
Hello Aleksey,

We tried to reproduce the issue with the code-snippet you provided but with no success. That is why I would like to ask you to create a sample application reproducing the issue and send it back to us. We need to reproduce the issue on our side in order to investigate the cause of the leak.

Looking forward to hearing from you.

Regards,
Kiril Vandov
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
TabControl
Asked by
Aleksey
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Aleksey
Top achievements
Rank 1
Share this question
or