I am having a similar problem, and I generated a short example to illustrate the problem. We are using a timer, but it happens to be a bit longer in cycle than the one supplied here. It just takes longer to run out of memory if the timer is longer. Note that the more items that are added to the chart, the larger the memory leak.
I also took the liberty of looking through the Telerik source code and discovered that RadChart contains 2 Chart objects, one directly, and one indirectly through MapAreaBuilder. RadChart does not implement Dispose, so these items hang around much longer than they should. MapAreaBuilder also does not implement dispose, and it should as well. The basic idea is that if a class includes an object that implements IDisposable, the containing class must also implement IDisposable and dispose of the Disposable objects it contains. Yes, RadChart does inherit from Control that implements IDispose, but Control does not know to dispose of the 2 Charts that are contained in the RadChart object. In other words, RadChart needs to override Dispose(bool) and dispose of the Chart and the MapAreaBuilder if the parameter passed in is true. MapAreaBuilder needs to derive from IDisposable, implement Dispose(), Dispose(bool) and ~MapAreaBuilder().
Default.aspx.cs
Default.aspx
I also took the liberty of looking through the Telerik source code and discovered that RadChart contains 2 Chart objects, one directly, and one indirectly through MapAreaBuilder. RadChart does not implement Dispose, so these items hang around much longer than they should. MapAreaBuilder also does not implement dispose, and it should as well. The basic idea is that if a class includes an object that implements IDisposable, the containing class must also implement IDisposable and dispose of the Disposable objects it contains. Yes, RadChart does inherit from Control that implements IDispose, but Control does not know to dispose of the 2 Charts that are contained in the RadChart object. In other words, RadChart needs to override Dispose(bool) and dispose of the Chart and the MapAreaBuilder if the parameter passed in is true. MapAreaBuilder needs to derive from IDisposable, implement Dispose(), Dispose(bool) and ~MapAreaBuilder().
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
namespace RadChartLeakTest
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Timer1Tick(object sender, EventArgs e)
{
}
}
}
Default.aspx
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="RadChartLeakTest._Default" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
asp:Content
ID
=
"HeaderContent"
runat
=
"server"
ContentPlaceHolderID
=
"HeadContent"
>
</
asp:Content
>
<
asp:Content
ID
=
"BodyContent"
runat
=
"server"
ContentPlaceHolderID
=
"MainContent"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadScriptBlock
ID
=
"Script1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
</
script
>
</
telerik:RadScriptBlock
>
<
asp:Panel
ID
=
"PanelUpdateThis"
runat
=
"server"
>
<
telerik:RadChart
runat
=
"server"
ID
=
"Chart1"
>
<
Appearance
Border-Visible
=
"false"
FillStyle-FillType
=
"Solid"
FillStyle-MainColor
=
"#f2f2f2"
>
</
Appearance
>
<
ChartTitle
Visible
=
"false"
>
</
ChartTitle
>
<
Legend
Appearance-Border-Visible
=
"false"
Appearance-FillStyle-FillType
=
"Solid"
Appearance-FillStyle-MainColor
=
"#f2f2f2"
>
</
Legend
>
<
PlotArea
Appearance-Border-Color
=
"#f2f2f2"
Appearance-FillStyle-MainColor
=
"#f2f2f2"
Appearance-FillStyle-FillType
=
"Solid"
EmptySeriesMessage-TextBlock-Text
=
"No Sessions Last 24 Hours"
EmptySeriesMessage-TextBlock-Appearance-TextProperties-Color
=
"Black"
>
<
XAxis
AutoScale
=
"false"
IsZeroBased
=
"true"
>
</
XAxis
>
</
PlotArea
>
<
Series
>
</
Series
>
</
telerik:RadChart
>
<
asp:Timer
ID
=
"Timer1"
runat
=
"server"
Interval
=
"1000"
OnTick
=
"Timer1Tick"
>
</
asp:Timer
>
</
asp:Panel
>
</
asp:Content
>