Silverlight DataTemplate - Leak Memory

3 posts, 0 answers
  1. Nelson
    Nelson avatar
    62 posts
    Member since:
    Apr 2011

    Posted 22 Nov 2011 Link to this post

    Hi there,

    In my silverlight application, I use a lot of gridViews and DataForms with DataTemplates, like this example:

    <telerik:RadGridView x:Name="grdMensagens" Margin="0 5 0 0" Visibility="{Binding Path=DataContext.VerGridAssuntosReuniao,ElementName=LayoutRoot}"
                                        ItemsSource="{Binding Path=DataContext.OCAssuntosReuniao,ElementName=LayoutRoot}"
                                        SelectedItem="{Binding Path=DataContext.AssuntoSeleccionado,Mode=TwoWay,ElementName=LayoutRoot}"
                                        Width="Auto" Height="330" MaxHeight="335" Grid.ColumnSpan="3" RowHeight="15"
                                        AutoGenerateColumns="False"  IsReadOnly="True"
                                        ShowGroupPanel="False" ShowColumnFooters="False" RowIndicatorVisibility="Collapsed"
                                            <swi:EventTrigger EventName="Loaded">
                                                <esi:CallDataMethod Method="grdAssuntos_Loaded"/>

                                            <telerik:GridViewDataColumn Header="Assunto" Width="0.9*">
                                                            <telerikHtml:HtmlDataProvider x:Name="HtmlProvider" RichTextBox="{Binding ElementName=LeitorTemplateNotif}" Html="{Binding ConteudoProp}"/>
                                                            <telerik:RadRichTextBox Height="Auto" HorizontalAlignment="Stretch" Margin="0" FontFamily="Arial" FontSize="10" BorderBrush="Transparent" BorderThickness="0" Background="Transparent" IsImageMiniToolBarEnabled="False" Name="LeitorTemplateNotif" IsReadOnly="True" Visibility="Visible" telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" Loaded="ProcessadorTextoSGA_Loaded"/>
                                            <telerik:GridViewDataColumn Header="Anexos" Width="0.1*">
                                                    <Style TargetType="telerik:GridViewCell">
                                                        <Setter Property="Template">
                                                                <ControlTemplate TargetType="telerik:GridViewCell">
                                                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                                                        <Button Margin="1" Height="25" Width="25" Foreground="#FFFFFFFF" HorizontalAlignment="Center" VerticalAlignment="Center" Command="{Binding Path=DataContext.CmdVerAnexos,ElementName=LayoutRoot}" CommandParameter="{Binding IdProp}" Style="{StaticResource GlassButton}" ToolTipService.ToolTip="Clique para ver os detalhes do documento">
                                                                                <StackPanel HorizontalAlignment="Left" Width="Auto" Height="Auto" Orientation="Horizontal">
                                                                                <Image Grid.Column="0" HorizontalAlignment="Stretch" Source="{Binding Icone}" Height="20" Width="20" Stretch="Fill"/>

    And my application have a lot of leaks of memory, if I let the application running for 1 hour the memory used by my application goes unitl 1GB!!!! This is a lot for one simple web application!!!

    So I decide investigate and read that DataTemplates are not collected by GC.

    So, what is the solution? This is very important. I also read that this behaviour doesn´t occure in Silverlight 3...

    Please, i need help here.

    Thanks in advance.

    Nelson Silva
  2. Nedyalko Nikolov
    Nedyalko Nikolov avatar
    871 posts

    Posted 25 Nov 2011 Link to this post

    Hi Nelson,

    This problem is fixed with Silverlight 4 (4.0.50826.0) release.
    Please take a look at this link for more info.

    Best wishes,
    Nedyalko Nikolov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Nelson
    Nelson avatar
    62 posts
    Member since:
    Apr 2011

    Posted 25 Nov 2011 Link to this post

    Hi Nedyalko,

    I'm using this version of silverlight, but the problem still exists. Another question...and about commanding? I use a lot of commands inside a DataTemplate, I read about it, and seems that command inside templates are not collected by garbage collector? This is true? and if yes, how fix?


    Nelson Silva

Back to Top