Memory Leak Custom3DGrid

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
HCCKPM_2020
Newbie
Newbie
Posts: 25
Joined: Wed Jul 01, 2020 12:00 am

Memory Leak Custom3DGrid

Post by HCCKPM_2020 » Wed Sep 30, 2020 8:26 am

Hello,

we have a Memory Leak in Custom3DGrid.
Each access will let the memory grow.
Is there a knwon issue with Custom3DGrid?

System:
TeeChart Version 4.2020.5.25
IDE: VS2019
Language: C#
Windows 10 Pro 1909
Best regards,

HCC/KPM

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Memory Leak Custom3DGrid

Post by Christopher » Thu Oct 01, 2020 7:04 am

Hello,

Despite being a public class, Custom3DGrid was not designed to be instantiated - it was designed as a base class, and as such is the base class of the classes ColorGrid, Contour, Surface, and Tower. Which of these four series types are you using? Could you please send us a Short, Self Contained, Correct (Compilable), Example (defined here) with which we can reproduce your issue?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

HCCKPM_2020
Newbie
Newbie
Posts: 25
Joined: Wed Jul 01, 2020 12:00 am

Re: Memory Leak Custom3DGrid

Post by HCCKPM_2020 » Thu Oct 01, 2020 7:46 am

Here you will find a sample project: https://hcckpm-my.sharepoint.com/:u:/g/ ... w?e=3Y6gGB

After each click the memory usage will grow. It will fall down after a few clicks but not to the starting point.
In the sample we use the ColorGrid.
We also tested the same behavior on a second system. That's the reason why it is not registered.
We also used the latest nuget downloadable version from September.
Start.jpg
Start.jpg (174.37 KiB) Viewed 13667 times
after_10_clicks.jpg
after_10_clicks.jpg (175.75 KiB) Viewed 13667 times
Best regards,

HCC/KPM

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Memory Leak Custom3DGrid

Post by Christopher » Thu Oct 01, 2020 10:59 am

Hello,

I've modified slightly your project to use a timer (which fires twice a second) instead of manually using a mouse:

Code: Select all

    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private Steema.TeeChart.WPF.Styles.ColorGrid seriesCG;
        private int clicks = 0;
        private DispatcherTimer _timer;


        public MainWindow()
        {
            InitializeComponent();

            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 500);
            _timer.Tick += _timer_Tick;
            InitChart();

            _timer.IsEnabled = true;
        }

        private void _timer_Tick(object sender, EventArgs e)
        {
            clicks++;
            NewData();
        }

        private void InitChart()
        {
            Chart1.Legend.LegendStyle = Steema.TeeChart.WPF.LegendStyles.Values;
            Chart1.Legend.Alignment = LegendAlignments.Bottom;

            Chart1.Aspect.View3D = false;

            seriesCG = new Steema.TeeChart.WPF.Styles.ColorGrid(Chart1.Chart);
            seriesCG.PaletteStyle = Steema.TeeChart.WPF.Styles.PaletteStyles.Rainbow;
            seriesCG.UseColorRange = false;
            seriesCG.UsePalette = true;

            seriesCG.Pen.Visible = false;

            NewData();
        }

        private void NewData()
        {
            int arraySizeX = 512;
            int arraySizeY = 360;
            int arraySize = arraySizeX * arraySizeY;

            short[] dataX = new short[arraySize];
            short[] dataZ = new short[arraySize];
            float[] dataY = new float[arraySize];

            int index = 0;
            int inv = 1;
            if ((clicks % 2) == 0) inv = -1;

            for (int x = 0; x < arraySizeX; x++)
            {
                for (int y = 0; y < arraySizeY; y++)
                {
                    dataX[index] = Convert.ToInt16(x);
                    dataZ[index] = Convert.ToInt16(y);
                    dataY[index] = index * inv / 1000;
                    index++;
                }
            }
            seriesCG.Clear();
            seriesCG.Add(dataX, dataY, dataZ);
            Chart1.Header.Text = clicks.ToString();
        }

        private void Chart1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            clicks++;
            NewData();
        }
    }
I then ran this code in a Memory Usage diagnostic session as detailed here using the latest publicly available version of Visual Studio 2019. I've uploaded the results here in the form of a *.diagsession file which you can open in Visual Studio 2019. The results look like this:
devenv_2020-10-01_12-07-57.png
devenv_2020-10-01_12-07-57.png (79.51 KiB) Viewed 13655 times
As you can see, this specific diagnostic session has failed to detect any kind of memory leak in the code.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply