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

[Solved] Severe memory leak

13 Answers 276 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tyree
Top achievements
Rank 2
Tyree asked on 01 Feb 2011, 10:41 PM
Upon upgrading our application to the latest version our users have been crashing daily out of memory. After doing some memory profiling I am never seeing memory freed up as we add and remove records from the grid. If I recompile using 3.1213 we do not experience this problem. 3.1314 will run us up to 2 gigs and crash. I do not have any more information at this point as I have to put this fire out.

I will try to produce an example asap.

13 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 02 Feb 2011, 07:43 AM
Hello,

 Please send us the application where we can reproduce and debug this once available. 

All the best,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Tyree
Top achievements
Rank 2
answered on 07 Feb 2011, 05:48 PM
I have not had time to create an example but I have opened a support ticket, please refer to that ticket.

In short it appears to be creating editors and not releasing them.
0
Vlad
Telerik team
answered on 08 Feb 2011, 08:19 AM
Hi,

 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
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Tyree
Top achievements
Rank 2
answered on 08 Feb 2011, 02:27 PM
As I stated in the ticket is am not using a GridViewComboBoxColumn - I am using CellEditTemplate. I cannot use a comboboxcolumn because not all of the functionality is provided as in the actual RadComboBox.

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>
0
Vlad
Telerik team
answered on 08 Feb 2011, 02:31 PM
Hi,

 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
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Michael Evans
Top achievements
Rank 1
answered on 14 Feb 2011, 07:59 PM
I'm seeing a very similar issue.  I'm using a custom user control that contains a RadComboBox in my CellEditTemplate.  Every time a new combo appears in the grid, it's gaining up to 7MB of memory that never goes away.  Only takes about 100 clicks before the app crashes.

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.
0
Vlad
Telerik team
answered on 15 Feb 2011, 08:13 AM
Hello,

 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
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Michael Evans
Top achievements
Rank 1
answered on 15 Feb 2011, 02:33 PM
Well, I can confirm that the Silverlight update does not fix this issue. 

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:

          xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
          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:x="http://schemas.microsoft.com/winfx/2006/xaml"
             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.
0
Tyree
Top achievements
Rank 2
answered on 15 Feb 2011, 06:40 PM
Likewise I tried the latest silverlight and it had no effect. Still working on porting my application to something you can use.

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.
0
Vlad
Telerik team
answered on 16 Feb 2011, 08:12 AM
Hello Michael,

 Can you remove temporary Loaded/Unloaded events registration to see if this is still leaking? 

Best wishes,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Michael Evans
Top achievements
Rank 1
answered on 16 Feb 2011, 02:52 PM
When I removed the Loaded and Unloaded event handlers, it appeared that the memory leak went away.

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.
0
Michael Evans
Top achievements
Rank 1
answered on 16 Feb 2011, 04:10 PM
I created a support ticket with a demo that causes the leak.  Ticket # is 395001.
0
Tyree
Top achievements
Rank 2
answered on 02 Mar 2011, 05:42 PM
I, too, have submitted a sample app.
Tags
GridView
Asked by
Tyree
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Tyree
Top achievements
Rank 2
Michael Evans
Top achievements
Rank 1
Share this question
or