Page 1 of 1

m_tchart.Series.Clear(); // Garbage collections issues.

Posted: Fri Feb 25, 2005 7:38 pm
by 8119975
I am loading very large amounts of data (well over 5MB per array of data) to be displayed. I have a button that I use to clear the chart. When I monitor my App's memory usage it does not seem to be reclaiming all the memory when I clear the chart. Inside my ClearChart() function I call m_tchart.Series.Clear(); but this does not seem to help. I did some experimenting and found that the putting the following code in my ClearChart() function works and memory is reclaimed:
for(int i = 0; i < m_tchart.Series.Count; ++i)
{
m_tchart.Series.Clear();
}
m_tchart.Series.Clear();

I am using the Fastline Series, Visual Studio .Net 2003, with Version 1.1 SP1 of the .Net Framework.

Is this the way it should work?

Posted: Mon Feb 28, 2005 12:46 pm
by narcis
Hi Digital,
Is this the way it should work?
Yes, that's right. Which was the problematic code?

m_tchart.Series.Clear(); // alone is the problem

Posted: Mon Feb 28, 2005 2:33 pm
by 8119975
m_tchart.Series.Clear(); alone is the problem. If I call only this line the memory does not seem to be reclaimed. I thought this method is supposed to clear and dispose of all series the then remove them from the chart. I does remove them from the chart but memory seems to hang around unless I manally loop through and clear each series one by one prior to the call to m_tchart.Series.Clear(); Only clearing the series one by one manually followed by the call to m_tchart.Series.Clear(); seems to allow the memory to be reclaimed.

Posted: Mon Feb 28, 2005 2:57 pm
by narcis
Hi Digital,

Ok, then you can try RemoveAllSeries:

Code: Select all

m_tchart.Series.RemoveAllSeries();

obsolete?

Posted: Mon Feb 28, 2005 3:14 pm
by 8119975
m_tchart.Series.RemoveAllSeries(); // This is not obsolete?

or is it that m_tchart.RemoveAllSeries(); is obsolete.

Posted: Mon Feb 28, 2005 3:21 pm
by narcis
Hi Digital,
m_tchart.Series.RemoveAllSeries(); // This is not obsolete
No.
or is it that m_tchart.RemoveAllSeries(); is obsolete.
This doesn't exist in the .NET version contrary to the VCL version.

Thanks

Posted: Mon Feb 28, 2005 3:33 pm
by 8119975
Thank you for your help.