To reproduce:
Have a RadButton and a RadChartView on a form. On button click use the following code:
private void GenerateSeries()
{
LineSeries lineSeries = new LineSeries();
lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan") { Label = "January" });
lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr"));
lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul"));
lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct"));
lineSeries.LegendTitle = "Line 1 ";
this.Chart.Series.Add(lineSeries);
lineSeries.BackColor = Color.Black;
lineSeries.PointSize = new SizeF(15, 15);
LineSeries lineSeries2 = new LineSeries();
lineSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Jan"));
lineSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Apr"));
lineSeries2.DataPoints.Add(new CategoricalDataPoint(17, "Jul"));
lineSeries2.DataPoints.Add(new CategoricalDataPoint(22, "Oct"));
lineSeries2.LegendTitle = "Line 2 ";
this.Chart.Series.Add(lineSeries2);
}
void RadButton_Click(object sender, EventArgs e)
{
this.Chart.Series.Clear();
this.GenerateSeries();
}
You will notice that the memory will not decrease after a few presses of the button.
Workaround:
Set the Provider of the LegendElement to null:
private void GenerateSeries()
{
this.Chart.ChartElement.LegendElement.Provider = null;
LineSeries lineSeries = new LineSeries();
lineSeries.DataPoints.Add(new CategoricalDataPoint(20, "Jan") { Label = "January" });
lineSeries.DataPoints.Add(new CategoricalDataPoint(22, "Apr"));
lineSeries.DataPoints.Add(new CategoricalDataPoint(12, "Jul"));
lineSeries.DataPoints.Add(new CategoricalDataPoint(19, "Oct"));
lineSeries.LegendTitle = "Line 1 ";
this.Chart.Series.Add(lineSeries);
lineSeries.BackColor = Color.Black;
lineSeries.PointSize = new SizeF(15, 15);
LineSeries lineSeries2 = new LineSeries();
lineSeries2.DataPoints.Add(new CategoricalDataPoint(18, "Jan"));
lineSeries2.DataPoints.Add(new CategoricalDataPoint(15, "Apr"));
lineSeries2.DataPoints.Add(new CategoricalDataPoint(17, "Jul"));
lineSeries2.DataPoints.Add(new CategoricalDataPoint(22, "Oct"));
lineSeries2.LegendTitle = "Line 2 ";
this.Chart.Series.Add(lineSeries2);
}
void Button_Click(object sender, EventArgs e)
{
this.Chart.Series.Clear();
this.GenerateSeries();
}