Page 1 of 3

Memory Usage keep increasing when auto scrolling chart

Posted: Mon Feb 06, 2012 7:43 am
by 15659548
Hi,

I have a tChart which has a X axis as the Time. I want the X asis to auto scroll as time passed.
I found a solution to do this auto scrolling here :
http://www.teechart.net/support/viewtop ... 10&t=11426

If I leave the chart to runs for 2 hours, I observe that the memory usage keep increasing.

I though that its due to having too may data points on my chart. So I created a test application which limits the number of data points to 10.

Again, I see that memory usage keep increasing.

So, is the way of using the SetMinMax() to make the auto scrolling the recommended way?

The source codes of the test application is as follows :

Code: Select all

    public partial class Form1 : Form
    {
        private const int MAX_DATA = 10;

        public Form1()
        {
            InitializeComponent();
            tChart1.Text = "My Chart Text";
            tChart1.Aspect.View3D = false;

            FastLine fl1 = new FastLine();
            fl1.Title = "My Line 1";
            fl1.Color = Color.Blue;
            tChart1.Series.Add(fl1);
            tChart1.Series[0].Clear();

            tChart1.Axes.Bottom.AutomaticMinimum = false;
            tChart1.Axes.Bottom.AutomaticMaximum = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void OnTimerTick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            tChart1.Series[0].Add(dt, tChart1.Series[0].XValues.Count + 1);
            if (tChart1.Series[0].XValues.Count > MAX_DATA)
            {
                tChart1.Series[0].XValues.RemoveAt(0);
                tChart1.Series[0].YValues.RemoveAt(0);
            }
            UpdateTimeAxis(dt);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Stop();
        }

        private void UpdateTimeAxis(DateTime maxTime)
        {
            DateTime minScrollDateTime = maxTime.Subtract(new TimeSpan(0, 0, 10));
            tChart1.Axes.Bottom.Minimum = minScrollDateTime.ToOADate();
            tChart1.Axes.Bottom.Maximum = maxTime.ToOADate();
        }
    }


Re: Memory Usage keep increasing when auto scrolling chart

Posted: Mon Feb 06, 2012 3:52 pm
by 10050769
Hello jsdu,

Can you tell us which version of TeeChart.Net are you using? So, I can not reproduce it in last version of TeeChartFor.Net.

Thanks,

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Tue Feb 07, 2012 2:36 am
by 15659548
Hi Sandra,

Sorry, I have missed a function.
In the previous code, the time shown in the X Axis is the clock time.
However, we wanted to show the Elapsed time. So we created Labels. However, our chart has several Series (ie several Lines) and we only can have Label for 1 of the Series.
So we have the following function to clear the Labels for all Series, find out which Series has the most Data Points, and recreate the Labels for that Series.
This way, the X Axis will show the Elapsed time.

This function is called inside the OnTimerTick() after the Data Point is added.

Code: Select all

        private void ReFormatXTimeAxis()
        {
            Series longestSeries = tChart1.Series[0];
            foreach (Series series in tChart1.Series)
            {
                if (series.XValues.Count > longestSeries.XValues.Count)
                    longestSeries = series;

                series.Labels.Clear();
            }
            DateTime firstValue = longestSeries.XValues.AsDateTime(0);
            for (int i = 0; i < longestSeries.XValues.Count; i++)
            {
                    TimeSpan span = longestSeries.XValues.AsDateTime(i).Subtract(firstValue);
                    longestSeries.Labels.Add(span.ToString());
            }
        }

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Tue Feb 07, 2012 4:21 pm
by 10050769
Hello jdsu,

Thanks for your code. Other question, can you tell us which version of TeeChart.Net you are using, because it would be very helpful for us know this.

Thanks,

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Tue Feb 07, 2012 5:38 pm
by 15659548
Hi Sandra,

I suppose it is TeeChart for .NET 2010.
I'm using VS 2008.

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Thu Feb 09, 2012 3:06 am
by 15659548
Hi Sandra,

In the code in the first post, I have only 1 Series. That is, the chart will draw 1 line only.
I have since tried modifying the code to have 30 Series. In the OnTimerTick(), I randomly add the data point to one of the Series.
Doing so, when I have 30 Series, I noticed the memory usage increase seems slower as compared to have only 1 Series.

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Fri Feb 10, 2012 3:09 pm
by 10050769
Hello jdsu,

I inform you that there are a newest maintenance releases of TeeChart, I recommend update your version and check again if your problem persist. On the other hand, Can you please send us your project because using previous code and adding 30 Series the behavior of memory use is the same increase slower.

Thanks,

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Mon Feb 13, 2012 1:34 pm
by 15659548
Hi Sandra,

Unfortunately, I only have 1 work machine. If I upgraded my TeeChart, it will affect the work on our Application. The References will be messed up.

Can I email you the project ZIP file?
Anyway, do you see the memory keep increasing if youleave the test application running for > 1 hr?

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Mon Feb 13, 2012 2:21 pm
by 15659548
Hi Sandra,

I'm not sure if I have been clear. I'm not comparing whether 3 Series or 30 Series will have more memory increases.
I have limit the data points to 1000 by removing older data points each time I add new data points.
So I do not expect the memory to keep increasing.
We need to be able to run the application non-stop for > 24 hours. Such increase of memory is causing "Out of Memory" error in our application after a few hours of running.

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Tue Feb 14, 2012 3:08 am
by 15659548
Hi Sandra,

I have attached the Test Application I have used to investigate this memory usage problem.
Please see TChartTest1.zip.

You can compile and run. Open the Task Manager and note down the Memory usage. Let it run for 2 hours and then note down the Memory usage.
Then let it run for another 2 hours and then note down the Memory usage.
You will see that the memory usage keep increasing.

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Tue Feb 14, 2012 8:55 am
by 15659548
Hi Sandra,

I managed to borrow a machine for me to perform a fresh installation.
On this machine, I installed this version : TeeChartNET2010VSNET2008_4.1.2011.04192.exe

It seems to be the latest for TeeChart .NET 2010.

I run the test application which I attached in the previous post. My finding is that the memory is still increasing.
At 30 minutes, the memory is about 30Mb.
At 1 hrs, the memory is about 40Mb.
At 4 hrs, the memory is about 80Mb.

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Wed Feb 15, 2012 5:22 pm
by 10050769
Hello jdsu,

We are investigating your problem, we try to answer you asap.

Thanks,

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Wed Feb 22, 2012 2:56 am
by 15659548
Hi Sandra,

Any updates on why the memory usage keep increasing?

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Thu Feb 23, 2012 12:41 pm
by 10050769
Hello jdsu,

I inform you that your application keeps memory usage in same range, after 3 hours (40-50 MB) in my computer. Therefore, I cannot reproduce your problem here using last version of TeeChart.Net ( 4.1.2012.01032). I can see that you use a previous build of TeeChart.Net 4.1.2011.04192 instead of last build 4.1.2012.01032. I recommend you update your TeeChartFor.Net version and try again if your problem of memory use persists. You can download last version of TeeChart.Net in download page, if you have any problem with your keys, please contact with the person controls the licences of TeeChart or send an email to our Sales Dept. at sales at steema dot com to get more information about it.

I hope will helps.

Thanks,

Re: Memory Usage keep increasing when auto scrolling chart

Posted: Fri Feb 24, 2012 1:48 am
by 15659548
Hi Sandra,

In the download page, the latest version listed is this :
TeeChartNET2011_4.1.2012.01030.exe
January 09, 2012
Build 4.1.2012.01030
File size - 166,26 MB

How do I get the v4.1.2012.01032?