I am using Telerik RadChart for our sales persons target&realization&performance graphics (at least 2000 person's charts * 3 times for every entrance to the system). When i use asp.net for creating images on the fly, there is going to have a memory problem in IIS. It is going higher and higher and at last application server gives "Out of memory" error. So i determined that, i am going to preprocess those images and will going to show. So there will not be any problem on web server i thought.
But, i have another problem on this new issue. I take all the code to the winform and create a new windows application to create all charts. After that, when i tried to create charts, again the memory usage is going higher for each time i saved the chart.
In my Code, there is a radChart1 object, which has one serie for a line, XAxis and YAxis properties are also specified. So in the code behind, I wrote this code;
******************************
DataSet
dsMsas = new DataSet(); //
dsMsas = df.GetMsas(); // it is getting from a database function class (all sales persons)
for (int i = 0; i < dsMsas.Tables[0].Rows.Count; i++)
{
Telerik.WinControls.UI.
RadChart rc = new Telerik.WinControls.UI.RadChart();
rc = (Telerik.WinControls.UI.
RadChart) radChart1.Clone();
try
{
string intMsaCode = dsMsas.Tables[0].Rows[i][0].ToString();
DataSet ds = new DataSet();
ds = df.GetMI(intMsaCode); //get Market Index data for sales persons
Double dblMinValue = 0, dblMaxValue = 0;
ChartSeries miDataSeries = rc.GetSeries("Series 1"); // only one serie in the chart
rc.ChartTitle.TextBlock.Text =
"MI " + ds.Tables[0].Rows[0][2].ToString() + " / " + ds.Tables[0].Rows[0][3].ToString();
if (miDataSeries != null)
{
dblMinValue =
Convert.ToDouble(ds.Tables[0].Rows[0][1]);
dblMaxValue = dblMinValue;
miDataSeries.DefaultLabelValue =
"#Y{N0}";
foreach (DataRow dbRow in ds.Tables[0].Rows)
{
if (dblMinValue > Convert.ToDouble(dbRow["pdMIMS"]))
dblMinValue =
Convert.ToDouble(dbRow["pdMIMS"]);
if (dblMaxValue < Convert.ToDouble(dbRow["pdMIMS"]))
dblMaxValue =
Convert.ToDouble(dbRow["pdMIMS"]);
rc.PlotArea.XAxis.AddItem(dbRow[
"psMonthName"].ToString().Substring(0, 3));
miDataSeries.AddItem(
Convert.ToDouble(dbRow["pdMIMS"]));
}
}
double dblAvgValue = Convert.ToInt32((dblMaxValue - dblMinValue) / ds.Tables[0].Rows.Count);
rc.PlotArea.YAxis.MaxValue =
Convert.ToDouble(Convert.ToInt32(dblMaxValue) + dblAvgValue);
rc.PlotArea.YAxis.MinValue =
Convert.ToDouble(Convert.ToInt32(dblMinValue) - dblAvgValue);
int intStep = Convert.ToInt32((rc.PlotArea.YAxis.MaxValue - rc.PlotArea.YAxis.MinValue) / ds.Tables[0].Rows.Count);
rc.PlotArea.YAxis.Step = intStep <= 0 ? 1 : intStep;
rc.Save(
"MainPageImages/MI/" + intMsaCode + "_MI.png", System.Drawing.Imaging.ImageFormat.Png);
//after this part the memory is going higher, when i throw this part there is nothing happened, no memory usage.
miDataSeries.Clear();
rc.PlotArea.YAxis.Clear();
rc.PlotArea.XAxis.Clear();
rc.Dispose();
rc =
null;
}
catch (Exception ex)
{
//nothing
string strE = ex.Message;
}
}
dsMsas =
null;
*****************************************SO, what can i do for that, i must solve this problem urgently.