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

Silverlight DataTemplate - Leak Memory

2 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Nelson
Top achievements
Rank 1
Nelson asked on 22 Nov 2011, 03:47 PM
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}"
                                    BorderThickness="0"
                                    Width="Auto" Height="330" MaxHeight="335" Grid.ColumnSpan="3" RowHeight="15"
                                    AutoGenerateColumns="False"  IsReadOnly="True"
                                    ShowGroupPanel="False" ShowColumnFooters="False" RowIndicatorVisibility="Collapsed"
                                    LoadingRowDetails="grdMensagens_LoadingRowDetails"
                                    Cursor="Hand">
                                    <swi:Interaction.Triggers>
                                        <swi:EventTrigger EventName="Loaded">
                                            <esi:CallDataMethod Method="grdAssuntos_Loaded"/>
                                        </swi:EventTrigger>
                                    </swi:Interaction.Triggers>
                                    <telerik:RadGridView.Columns>

                                        <telerik:GridViewDataColumn Header="Assunto" Width="0.9*">
                                            <telerik:GridViewDataColumn.CellTemplate>                                                
                                                <DataTemplate>
                                                    <StackPanel>
                                                        <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"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </telerik:GridViewDataColumn.CellTemplate>
                                        </telerik:GridViewDataColumn>
                                        <telerik:GridViewDataColumn Header="Anexos" Width="0.1*">
                                            <telerik:GridViewColumn.CellStyle>
                                                <Style TargetType="telerik:GridViewCell">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <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"/>
                                                                            </StackPanel>
                                                                        </Button>
                                                                </StackPanel>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </telerik:GridViewColumn.CellStyle>
                                        </telerik:GridViewDataColumn>
                                    </telerik:RadGridView.Columns>
                                </telerik:RadGridView>
                            </StackPanel>
                        </telerik:RadTabItem.Content>
                    </telerik:RadTabItem>

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 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 25 Nov 2011, 08:46 AM
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 >>

0
Nelson
Top achievements
Rank 1
answered on 25 Nov 2011, 10:37 AM
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?


Thanks,

Nelson Silva

Tags
GridView
Asked by
Nelson
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Nelson
Top achievements
Rank 1
Share this question
or