0

In my application, I have added the possibility to show a live graph showing the telemetry data that I received. I have about 25 series spread 5 chartArea.

When I start the graph, everything is fine, but after some time (10/15 minutes), the application becomes really slow.

I think that there is a memory problem. I can see that the heap garbage collection often running when it was only running every 30s when those graphs are OFF.

enter image description here

I am not sure if this is a problem from the library, which is maybe no supposed to be used to plot so much point, or if it is because I'm not handling it as it should be.

Here is an example of my code:

    public partial class FluidicsDataGraphForm : graphTime
    {
        public FluidicsDataGraphForm()
        {
            InitializeComponent();

        }

        [...]

        public void UpdateFluidicsVDD(double AddedValueX, double AddedValueY)
        {
            DefaultDataChart.Series["VDD (V)"].Points.AddXY(AddedValueX, AddedValueY);
            if (AddedValueX > plotTime)
            {
                plotTime = AddedValueX;
            }
        }

        public void UpdateFluidicsCurrentConsumption(double AddedValueX, double AddedValueY)
        {
            DefaultDataChart.Series["Current consumption (A)"].Points.AddXY(AddedValueX, AddedValueY);
            if (AddedValueX > plotTime)
            {
                plotTime = AddedValueX;
            }
        }

        [...]

    }



    public partial class MainForm : DockContent
    {
        private void UpdateGraph(bool gotData) /* This function is called every time we compute the data, i.e. every 0.5 secondes */
        {
            if (FluidicsGraphData)
            {
                try
                {
                    FluidicsPlotTime += GeneralTimerStep;

                    if (m_solutionexplorer.IsNodeChecked("FluidicsTelemetry", "FluidicsTelemetryVDD") && gotData)
                    {
                        m_fluidicsdatagraphform.UpdateFluidicsVDD(FluidicsPlotTime, Convert.ToDouble(m_fluidicsform.FluidicsVDDValue));
                    }
                    else
                    {
                        m_fluidicsdatagraphform.UpdateFluidicsVDD(FluidicsPlotTime, double.NaN);
                    }

                    if (m_solutionexplorer.IsNodeChecked("FluidicsTelemetry", "FluidicsTelemetryCurrent") && gotData)
                    {
                        m_fluidicsdatagraphform.UpdateFluidicsCurrentConsumption(FluidicsPlotTime, Convert.ToDouble(m_fluidicsform.FluidicsCurrentValue));
                    }
                    else
                    {
                        m_fluidicsdatagraphform.UpdateFluidicsCurrentConsumption(FluidicsPlotTime, double.NaN);
                    }

                    [...]
                }
                catch { }
           }
           [...]
        }
   }

The result is a graph with a flow chart where the user can select the time per division and see the previous point, so I need to keep all the points. I cannot just delete them when the graph doesn't show them anymore. enter image description here

As I said, i have about 25 series like this one which use the same kind of code. Can I really use the DataVisualization.Charting to plot a Real Time graph with so much point? Why does the garbage collection is called so many times?

  • MSChart is meant to display business data like Pie charts, not animated live charts. You should consider [removing](https://stackoverflow.com/questions/50076045/chart-auto-scroll-oscilloscope-effect/50077332#50077332) datapoints from the left while adding new ones beyond a few hundred or thousand.. – TaW Jun 12 '20 at 09:53
  • Oh I see, thank you @TaW. I will try to find another library then. If I don't, I will consider removing datapoints. – Antoine Boré Jun 12 '20 at 11:01

0 Answers0