Page 1 of 1

Memory Leak in Pocket PC Version

Posted: Fri May 20, 2011 9:25 am
by 15657878
Hallo everybody, I have a problem with the memory in the pocket Pc Version.

Every second i update the chart, eventually with another chart typ (line, bar, ...):

Code: Select all

        private Timer timer = new Timer();

        public Form1()
        {
            InitializeComponent();

            InitializeChart();
        }

        Steema.TeeChart.Styles.Line line1;
        private void InitializeChart()
        {
            tChart1.Legend.Visible = false;
            tChart1.Aspect.View3D = false;

            line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues();

            tChart1.DoubleClick += new EventHandler(tChart1_DoubleClick);

            timer.Interval = 1000;
            timer.Enabled = true;
            timer.Tick += new EventHandler(timer_Tick);
        }

        void timer_Tick(object sender, EventArgs e)
        {
            tChart1_DoubleClick(null, null);
        }

        void tChart1_DoubleClick(object sender, EventArgs e)
        {
            tChart1.Clear();
            
            tChart1.Series.Clear();
            tChart1.Series.Add(line1);

            Random rnd = new Random();
            tChart1.AutoRepaint = false;
            line1.Clear();
            line1.Add(rnd.Next(100));
            for (int i = 1; i < 20; i++)
            {
                line1.Add(line1.YValues.Value[i - 1] + rnd.Next(10) - 5);
            }
            tChart1.AutoRepaint = true;
            tChart1.Refresh();
        }
After 5 min the memory on my Pocket PC is on an critical state.

Re: Memory Leak in Pocket PC Version

Posted: Fri May 20, 2011 2:00 pm
by narcis
Hi FH Nürnberg,

I have been running your code here for about 10 minutes without problems. I'm using Visual Studio 2008 with built-in USA Windows Mobile 5.0 Pocket PC R2 Emulator. Garbage collector seems to do its job with DeviceEmulator.exe. It uses 128 MB RAM:
PocketPCEmulator.jpg
PocketPCEmulator.jpg (70.26 KiB) Viewed 8078 times
Which environment are you using? Do you use a device or an emulator? How much memory does it use? Can you reproduce this using an emulator? During how many time do you have to run the app?

Thanks in advance.

Re: Memory Leak in Pocket PC Version

Posted: Mon May 23, 2011 6:53 am
by 15657878
Hallo Narcis,
I use the Visual Studio 2008 Professional Edition, with the Pocket PC 2003 SE-Emulator, with 64 MB RAM.
I modified the Emulator that the video output are 640 x 480 Pixel, the same as my device.

After 9 min the program has an OutOfMemory Exception in the line “tChart1.Clear()” the first line in tChart1_DoubleClick.

Under properties => storage => I found the total data / program storage, at the beginning it has 29.7 MB.

Re: Memory Leak in Pocket PC Version

Posted: Mon May 23, 2011 6:59 am
by 15657878
PS: I run the program alone (only I open the window "properties => storage" to see the RAM status.

I measured the 9 min with my watch and the error is reproduceable.

Re: Memory Leak in Pocket PC Version

Posted: Tue May 24, 2011 9:57 am
by 10050769
Hello FH Nürnberg,

Can you please check if you can reproduce the problem using exactly the same emulator that uses Narcís?

Thanks,

Re: Memory Leak in Pocket PC Version

Posted: Tue May 24, 2011 10:51 am
by 15657878
I have try to run the sample with the "GER Windows Mobile 5.0 Pocket PC Emulator" but after the synchronation with the PC.

An error appears that the Version of Microsoft .Net Compact Framework not correct is.

I don`t know why this emulator doesn´t work.

The Emulator "Ger Windows Mobile 5.0 Smartphone R2 QVGA Emulator" after 4 Min the program close with out a warning.

Re: Memory Leak in Pocket PC Version

Posted: Tue May 24, 2011 3:58 pm
by 10050769
Hello FH Nürnberg,

Ok. In first project I can reproduce your problem using last version of TeeChart.Net and VS2008 Pocket PC 2003 SE-Emulator, with 64 MB RAM:
SmartDeviceProject1.zip
(15.97 KiB) Downloaded 305 times
In second project doesn't reproduce your problem here using last version of TeeChart.Net and VS2008 USA Windows Mobile 5.0 Pocket PC R2 Emulator, with 128 MB RAM:
SmartDeviceProject2.zip
(11.13 KiB) Downloaded 293 times
Please, can you check two projects and confirm us if in both appears your problem?

Moreover, you can tell us which version of TeeChart are you using now?

Thanks,

Re: Memory Leak in Pocket PC Version

Posted: Wed May 25, 2011 6:51 am
by 15657878
Hallo Sandra,

the first project crushed after 9 min with OutofMemory. The second doesn´t run because I use the "Ger Windows Mobile 5.0 Pocekt PC R2 Emulator" and the compact framework can´t update.

I use the TeeChart version 4.1.2011.4192
with the runtime version v2.0.50727

Thanks,

Re: Memory Leak in Pocket PC Version

Posted: Thu May 26, 2011 11:04 am
by 10050769
Hello FH Nürnberg,

Ok. We have reproduced the same problem using WinForms application and we found that its a memory leak in the TChart.Clear(). We have fixed it for next maintenance release and at the moment you can use next workaround:

Code: Select all

private void TChartClear()
{
 tChart1.Chart.Dispose();
 tChart1.Chart = new Steema.TeeChart.Chart();
 tChart1.Chart.Parent = tChart1;
 tChart1.Chart.Parent.SetChart(tChart1.Chart);
 tChart1.Chart.Parent.DoSetControlStyle();
 tChart1.Chart.Parent.DoInvalidate();
}

void tChart1_DoubleClick(object sender, EventArgs e)
{
   TChartClear();
   //tChart1.Clear();
   tChart1.Series.Clear();
   tChart1.Series.Add(line1);

   Random rnd = new Random();
   tChart1.AutoRepaint = false;
   line1.Clear();
   line1.Add(rnd.Next(100));
   for (int i = 1; i < 20; i++)
   {
     line1.Add(line1.YValues.Value[i - 1] + rnd.Next(10) - 5);
   }
   tChart1.AutoRepaint = true;
   tChart1.Refresh();
}
Please, can you confirm us if previous code works as you expected?

Thanks,

Re: Memory Leak in Pocket PC Version

Posted: Thu May 26, 2011 11:33 am
by 15657878
Hallo Sandra,

thank you for the workaround, it works the memory is still the same after 10 min :wink:


Thank you

Re: Memory Leak in Pocket PC Version

Posted: Fri May 27, 2011 8:15 am
by 10050769
Hello FH Nürnberg,

I am glad that the solution works for you and solve your problem.

Thanks,