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

Memory leak

6 Answers 142 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 17 Dec 2010, 09:03 AM

Hello,

I think I found a memory leak.

The source code for my program - XAML:

<Grid x:Name="LayoutRoot" Background="White">
   <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="*" />
   </Grid.ColumnDefinitions>
   <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="*" />
      <RowDefinition Height="*" />
   </Grid.RowDefinitions>
 
   <telerikChart:RadChart Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" x:Name="radChart">
   <telerikChart:RadChart.DefaultView>
      <telerikCharting:ChartDefaultView>
          <telerikCharting:ChartDefaultView.ChartArea>
              <telerikCharting:ChartArea LegendName="chartLegend">
                  <telerikCharting:ChartArea.DataSeries>
                       <!-- Doughnut Chart -->
                       <telerikCharting:DataSeries>
                            <telerikCharting:DataSeries.Definition>
                                 <telerikCharting:DoughnutSeriesDefinition ItemLabelFormat="p">
                                 </telerikCharting:DoughnutSeriesDefinition>
                             </telerikCharting:DataSeries.Definition>
                             <telerikCharting:DataPoint YValue="0.215208267" LegendLabel="Toyota"/>
                             <telerikCharting:DataPoint YValue="0.192960612" LegendLabel="General Motors"/>
                             <telerikCharting:DataPoint YValue="0.151830229" LegendLabel="Volkswagen"/>
                             <telerikCharting:DataPoint YValue="0.125964366" LegendLabel="Ford"/>
                             </telerikCharting:DataSeries>
                         </telerikCharting:ChartArea.DataSeries>
                     </telerikCharting:ChartArea>
                 </telerikCharting:ChartDefaultView.ChartArea>
             </telerikCharting:ChartDefaultView>
         </telerikChart:RadChart.DefaultView>
     </telerikChart:RadChart>
 
     <telerik:RadRichTextBox Grid.Row="0" Grid.Column="1" Margin="10" x:Name="rRichTextBox1" IsReadOnly="True" />
     <telerik:RadRichTextBox Grid.Row="1" Grid.Column="1" Margin="10" x:Name="rRichTextBox2" IsReadOnly="True" />
     <telerik:RadRichTextBox Grid.Row="2" Grid.Column="1" Margin="10" x:Name="rRichTextBox3" IsReadOnly="True" />
</Grid>

And the code behind:
public MainPage()
{
    InitializeComponent();
 
    radChart.DefaultView.ChartArea.ItemClick += ChartArea_ItemClick;
}
 
void ChartArea_ItemClick(object sender, Telerik.Windows.Controls.Charting.ChartItemClickEventArgs e)
{
    HtmlFormatProvider html = new HtmlFormatProvider();
 
    rRichTextBox1.Document = html.Import(AddText(e.DataPoint.LegendLabel, e.DataPoint.YValue.ToString()));
    rRichTextBox2.Document = html.Import(AddText(e.DataPoint.LegendLabel, e.DataPoint.YValue.ToString()));
    rRichTextBox3.Document = html.Import(AddText(e.DataPoint.LegendLabel, e.DataPoint.YValue.ToString()));
}
 
private string AddText(string item, string value)
{
    StringBuilder builder = new StringBuilder();
    builder.Append("<table>");
    builder.Append("<tr>");
    builder.Append("<td>");
    builder.Append("<b>Item clicked:</b>");
    builder.Append("</td>");
    builder.Append("<td>");
    builder.Append("<b>Value:</b>");
    builder.Append("</td>");
    builder.Append("</tr>");
    builder.Append("<tr>");
    builder.Append("<td>");
    builder.Append(item);
    builder.Append("</td>");
    builder.Append("<td>");
    builder.Append(value);
    builder.Append("</td>");
    builder.Append("</tr>");
    builder.Append("</table>");
    builder.Append("<p>And some extra text: RadChart for Silverlight is the exact tool to transform various business scenarios into interactive, rich, animated charts that enable the end users to analyze complex data. Telerik Silverlight Chart is a 100% lookless control providing full support for Expression Blend.  All 2D series, charts and axis elements can be dropped independently in Blend and styled individually. Furthermore the control offers several pre-defined skins, which will help you to deliver a consistent look and feel in your application.application best.</p>");
 
    return builder.ToString();
}

Run this program and click chart control few times (memory usage will increase).

In this simple program memory usage stopped increasing after a while, but in my real application (where data is loaded from a database) – it never stops.

6 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 22 Dec 2010, 06:36 PM
Hello Andrew,
We did reproduce the issue, and it will be immediately fixed and included in the Q3 SP1, which is coming in a week or so.

Please, excuse us for the inconvenience. We have added points to your account for this bug report. Don't hesitate to contact us if you have other questions.

Regards,
Boby
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Andrew
Top achievements
Rank 1
answered on 18 Jan 2011, 03:32 PM

Hello again.

Now I have service pack and the problem is still there. 
Similar problem is when I change RichTextBox to Chart and in ChartArea_ItemClick event I modify ItemsSource:
radChart.ItemsSource = new int[] { 12, 56, 23, 89, 12, 56, 34, 78, 32, 56 };
0
Ves
Telerik team
answered on 21 Jan 2011, 11:12 AM
Hello Andrew,

We verified that the memory leak in RadRichTextBox has been fixed in Q3.SP1. Our only concern is the SpellChecker, which creates a Dictionary that holds references to some strings. We will investigate the issues further, but since you have managed to reproduce the issue with a chart in place of the rich text boxes, I assume the problem does not lie there. Setting the IsSpellCheckingEnabled property to false may be a temporary workaround, especially if you are using the rich text boxes in ReadOnly mode.

As for the chart -- indeed, there is a small increase in memory usage in the scenario you have described. Our developers have already fixed some issues with memory usage in RadChart and they will continue to investigate and search for additional reasons for this behavior.

Best regards,
Ves
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
Matthew
Top achievements
Rank 1
answered on 04 Feb 2011, 09:29 PM
I am running into memory leaks when using the Dictionary object as well.  Do you have any idea when a fix for this issue will be released?  The memory loss is dramatic and crashes my application before very long.
0
jdgoulden
Top achievements
Rank 1
answered on 08 Feb 2011, 03:13 PM
I am experiencing enormous memory leaks in the RadChart control while dynamically updating the data series. Is anyone else experiencing these problems and how are you mitigating the issues. So far I've gotten a commitment that they are "working on it and will address it in an upcoming release", not really the answer I can give my customers.
0
Ves
Telerik team
answered on 09 Feb 2011, 05:35 PM
Hi,

Matthew: For the time being, please hide the pointmarks, tooltips and labels.

jdgoulden: As mentioned in our reply to your support ticket, please use the same workaround for the moment.

We will get back to you as soon we have any news.

Best regards,
Ves
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Chart
Asked by
Andrew
Top achievements
Rank 1
Answers by
Boby
Telerik team
Andrew
Top achievements
Rank 1
Ves
Telerik team
Matthew
Top achievements
Rank 1
jdgoulden
Top achievements
Rank 1
Share this question
or