Memory Usage keep increasing when auto scrolling chart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Mon Feb 06, 2012 7:43 am

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();
        }
    }


Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by Sandra » Mon Feb 06, 2012 3:52 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Tue Feb 07, 2012 2:36 am

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());
            }
        }

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by Sandra » Tue Feb 07, 2012 4:21 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Tue Feb 07, 2012 5:38 pm

Hi Sandra,

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

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Thu Feb 09, 2012 3:06 am

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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by Sandra » Fri Feb 10, 2012 3:09 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Mon Feb 13, 2012 1:34 pm

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?

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Mon Feb 13, 2012 2:21 pm

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.

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Tue Feb 14, 2012 3:08 am

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.
Attachments
TChartTest1.zip
(39.31 KiB) Downloaded 510 times

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Tue Feb 14, 2012 8:55 am

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.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by Sandra » Wed Feb 15, 2012 5:22 pm

Hello jdsu,

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

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Wed Feb 22, 2012 2:56 am

Hi Sandra,

Any updates on why the memory usage keep increasing?

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by Sandra » Thu Feb 23, 2012 12:41 pm

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,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

jdsu
Newbie
Newbie
Posts: 22
Joined: Tue Jun 14, 2011 12:00 am

Re: Memory Usage keep increasing when auto scrolling chart

Post by jdsu » Fri Feb 24, 2012 1:48 am

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?

Post Reply