I will try to produce an example asap.
13 Answers, 1 is accepted
Please send us the application where we can reproduce and debug this once available.
All the best,Vlad
the Telerik team
In short it appears to be creating editors and not releasing them.
I've checked your support ticket however according to the new information you have problems with RadComboBox inside CellEditTemplate. Do you have any more info about how this combo is bound? Any combo setting? I've tried this demo (which is with GridViewComboBoxColumn) and after tabbing up and few hundred times everything seems to work correctly - the memory is collected properly.
Regards,Vlad
the Telerik team
This is an example of A column but from my testing they all (or almost all) do it. Every time I re-enter a cell and it goes into edit mode another radcombobox is added to memory. I have a profile of 316 radcomboboxes in memory and in my scenario they are never destroyed. I have seen this with the datepicker also and a simple textbox.
<telerik:GridViewDataColumn Header="Gisb/Naesb K#" Width="150" DataMemberBinding="{Binding MySupplyContract.SupplyContractNbr}" IsReadOnlyBinding="{Binding EntitySupplyContract.IsReadOnly}" SortMemberPath="MySupplyContract.SupplyContractNbr" UniqueName="SupplyContractNbr"> <telerik:GridViewDataColumn.CellEditTemplate> <DataTemplate> <telerikInput:RadComboBox ItemsSource="{Binding DealGisbContractList, Mode=OneWay}" SelectedItem="{Binding EntitySupplyContract.MappedValue, Mode=TwoWay}" DisplayMemberPath="SupplyContractNbr" HorizontalContentAlignment="Right" IsEditable="True" IsReadOnly="True" GotFocus="RadComboBox_GotFocus"> <telerikInput:RadComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel/> </ItemsPanelTemplate> </telerikInput:RadComboBox.ItemsPanel> </telerikInput:RadComboBox> </DataTemplate> </telerik:GridViewDataColumn.CellEditTemplate> </telerik:GridViewDataColumn>Can you provide an example project with more info about how the combo is bound and what settings you've used?
Greetings,Vlad
the Telerik team
I confirmed this is NOT happening if the control only contains a TextBox. If there are any updates to this issue, please let me know.
We still cannot reproduce the reported issue and if you have an example project where we can reproduce this please send it to us. Furthermore there is a just released Silverlight update with lots of general memory leaks fixes related to inline DataTempalates, inline Styles, etc. - please test your case with this version as well.
Kind regards,Vlad
the Telerik team
Putting together a sample app is a difficult proposition as I am binding to RIA objects. Hopefully sharing some of the code will provide some insight. The CellEditTemplate looks like this:
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:controls='clr-namespace:MyNamespace.Controls;assembly=MyNamespace'> <controls:DailyValueComboBox AllData='{Binding Path=fieldname, Mode=TwoWay}' /> </DataTemplate>The control DailyValueComboBox is my own custom control. The XAML is:
<UserControl x:Class="MyNamespace.Controls.DailyValueComboBox" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:telerikinput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"> <Grid x:Name="LayoutRoot"> <TextBlock x:Name="theTextBlock" Visibility="Collapsed" Text="{Binding Path=Data, Mode=TwoWay}" /> <telerikinput:RadComboBox x:Name="theCombo" ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="Clear" VerticalAlignment="Center" ItemsSource="{Binding Path=LookupFieldValues}" DisplayMemberPath="Value" SelectedValuePath="Code" OpenDropDownOnFocus="True" telerik:AnimationManager.IsAnimationEnabled="False" SelectionChanged="RadComboBox_SelectionChanged" /> </Grid> </UserControl>And the codebind of the control:
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Telerik.Data; using MyNamespace.Web; namespace MyNamespace.Controls { public partial class DailyValueComboBox : UserControl { #region AllData (DependencyProperty) /// <summary> /// DataObject containing data and formatting for this value. /// </summary> public Telerik.Data.DataObject AllData { get { return (Telerik.Data.DataObject)GetValue(AllDataProperty); } set { SetValue(AllDataProperty, value); } } public static readonly DependencyProperty AllDataProperty = DependencyProperty.Register("AllData", typeof(Telerik.Data.DataObject), typeof(DailyValueComboBox), new PropertyMetadata(new Telerik.Data.DataObject())); #endregion public DailyValueComboBox() { InitializeComponent(); this.Loaded += new RoutedEventHandler(DailyValueComboBox_Loaded); this.Unloaded += new RoutedEventHandler(DailyValueComboBox_Unloaded); } void DailyValueComboBox_Unloaded(object sender, RoutedEventArgs e) { this.Unloaded -= DailyValueComboBox_Unloaded; if (theCombo != null) { theCombo.SelectionChanged -= RadComboBox_SelectionChanged; theCombo = null; } } void DailyValueComboBox_Loaded(object sender, RoutedEventArgs e) { this.Loaded -= DailyValueComboBox_Loaded; this.DataContext = (AllData.Data as List<Telerik.Data.DataObject>)[0]; if (theCombo.Items.Any(c => (c as Field_Value).Code == theTextBlock.Text)) { theCombo.SelectedItem = theCombo.Items.Where(c => (c as Field_Value).Code == theTextBlock.Text).First(); } } private void RadComboBox_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e) { if (theCombo != null && theCombo.SelectedItem != null) { theTextBlock.Text = (theCombo.SelectedItem as Field_Value).Code; } else { theTextBlock.Text = string.Empty; } } } } As you can see, I am disposing of the Loaded event as soon as it fires, and I have an Unloaded event that not only gets rid of the event handler to itself, but also the SelectionChanged event of the combo box.
In the above example, Field_Value is a RIA object. I hope this gives you the information you need to put together an example of this issue.
I have a workaround in place to release a good portion of the memory but I have one combobox that has an itemtemplate...and I cannot get the radcomboboxitem's to release no matter what I do. I have tried resting the itemssource, the selecteditem, and the itemtemplate...and they still sit in memory with no combobx attached to them.
Can you remove temporary Loaded/Unloaded events registration to see if this is still leaking?
Best wishes,Vlad
the Telerik team
However, the Loaded event is where I am setting the DataContext of the combo box. So there were no items in the dropdown list, which is probably the items that are going away.
What I did do is change the datacontext to be my own regular classes instead of RIA objects with all the overheard that entails. That seems to make things better. After clicking around and bringing up lots of combo boxes, the garbage collector seems to come in and free up some memory... but not all of it. For example I might click around in the grid and bring up 20-30 combos and the memory used will increase by 50 MB. The garbage collector collects about 20 MB or so of it, but the remaining 30 MB seems to stay permanently.
