Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 349

Summary: [TD29016647] Client found a memory leak using TeeChartDirect2D. Using the code I ...
Product: .NET TeeChart Reporter: sandra pazos <sandra>
Component: Direct2DAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED FIXED    
Severity: major    
Priority: Normal    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description sandra pazos 2013-11-20 11:24:59 EST
Client found a memory leak using TeeChartDirect2D.  Using the code I have attached below, the client and I, get the following levels of memory usage (KB) after short periods of running of the code
40,000 after 5s
50,000 after 10s
64,000 - 25s
80,000 - 30s
120,000 - 60s
500,000 - 300s
etc.
Client code that produced the Memory leak : 
using System;
using System;
using System.Windows.Forms;
using Steema.TeeChart.Drawing;
namespace MemLeakTest
{
    public partial class Form1 : Form
    {
        Steema.TeeChart.Styles.FastLine dsa;
        Steema.TeeChart.Styles.FastLine dsb;
        int xcounter;
        Timer timer1;
        public Form1()
        {
            InitializeComponent();
            timer1 = new Timer();
            timer1.Interval = 5;
            InitializeChart();
            xcounter = 1;
            timer1.Start();
            timer1.Tick +=new EventHandler(timer1_Tick);
        }
        private void InitializeChart()
        {
            dsa = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            dsb = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);
            Steema.TeeChart.Drawing.Direct2D.Graphics3DDirect2D D2D = new Steema.TeeChart.Drawing.Direct2D.Graphics3DDirect2D(tChart1.Chart); //(1)
            //InitializeChart
            D2D.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; //(2)
            D2D.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; //(3)
            tChart1.Graphics3D = D2D; //(4)
            tChart1.Graphics3D.BufferStyle = BufferStyle.None;
            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;
            tChart1.Header.Visible = false;
            tChart1.Footer.Visible = false;
            //InitializeAxes
            tChart1.Chart.Axes.Bottom.Title.Text = "Sample";
            tChart1.Chart.Axes.Left.Title.Text = "Signal";
            tChart1.Chart.Axes.Left.Automatic = false;
            tChart1.Chart.Axes.Left.Minimum = 0;
            tChart1.Chart.Axes.Left.Maximum = 1000;
            tChart1.Chart.Axes.Bottom.Automatic = true;
            tChart1.Chart.Axes.Bottom.Increment = 50;
            tChart1.Axes.Left.AxisPen.UseStyling = false;
            tChart1.Axes.Bottom.AxisPen.UseStyling = false;
            tChart1.Axes.Left.Grid.UseStyling = false;
            tChart1.Axes.Bottom.Grid.UseStyling = false;
            //FastLines
            dsa.LinePen.UseStyling = false;
            dsb.LinePen.UseStyling = false;
            tChart1.Panel.Pen.UseStyling = false;
        }         
        private void timer1_Tick(object sender, EventArgs e)
        {
             tChart1.AutoRepaint = false;
            if (dsa.Count > 300)
            {
                dsa.Delete(0);
                dsb.Delete(0);
            }
            dsa.Add(xcounter, 100);
            dsb.Add(xcounter, 300);
            xcounter++;
            tChart1.AutoRepaint = true;
            tChart1.Invalidate();
        }
    }
}
If you comment the lines 1-4,therefore you work with a winforms application, the problem isn't produced and the peak of memory is established around 500000kB for me.
Thread: http://www.teechart.net/support/viewtopic.php?f=4&t=14195&sid=6e6e8885c2fcc6e26ba199debb93a9e0&p=62460#p62460 [created:2013-07-17T12:47:02.000+01:00 reported by:sandra@steema.com reported in version:]