telerik:RadCartesianChart.Series.ScatterLineSeries increases application memory continuously while adding dynamic series datapoint at specific interval

0 Answers 25 Views
Chart
Renuka
Top achievements
Rank 1
Renuka asked on 30 Nov 2023, 02:06 PM

Hello,

I am facing application crash issue with : Out of memory exception.

While analysing, we got to know that scatterDataPoint is taking more memory

 

I am trying to add multiple ScatterLineSeries in telerik:RadCartesianChart.

XAML Code :


<telerik:RadCartesianChart Palette="Windows8" MouseDoubleClick="RadCartesianChart_MouseDoubleClick">
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:LinearAxis Minimum="0" 
                                    Maximum="5000"/>
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis Minimum="0" 
                                     Maximum="10000" />
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:RadCartesianChart.Series>
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Red" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Blue" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Pink" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Yellow" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Green" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Orange"/>
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="AliceBlue" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Black" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Violet" />
                <telerik:ScatterLineSeries ItemsSource="{Binding}" YValueBinding="YValue" XValueBinding="XValue" BorderBrush="Red" StrokeThickness="3" Stroke="Cornsilk" />
            </telerik:RadCartesianChart.Series>
        </telerik:RadCartesianChart>

 

I am updating value in specific time intervarl. Example:

We have created 1 observable collection in which we are adding plot values(xaxis,yaxis)


public class PlotInfo
        {
            public double XValue { get; set; }
            public double YValue { get; set; }
        }

ObservableCollection<PlotInfo> ColPlotInfo = new ObservableCollection<PlotInfo>();

//Initially adding 100 records in observable collection & binding values to CartesianChart series.

            ArrayPlotInfo = arrayPlotInfo = new ChartViewModel.PlotInfo[100];
            for (int i = 0; i<100; i++)
                {

                ColPlotInfo.Add(new ChartViewModel.PlotInfo() { XValue = i + 100, YValue = i + 101 });
                }

On double click of chart, we are adding records on Timer_Elapsed.


private void RadCartesianChart_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Timer timer = new Timer(100);
            timer.Enabled = true;
            timer.Elapsed += Timer_Elapsed;
            
        }
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {

            App.Current.Dispatcher.Invoke((Action)delegate
            {
                ChartViewModel.PlotInfo plotInfo = new ChartViewModel.PlotInfo() { XValue = (x = x + DateTime.Now.Second), YValue = DateTime.Now.Second };
                ColPlotInfo.Add(plotInfo);
            });
}

Here if we do not bind to series then memory is not icreaseing it only increases when we update graph and application gets crashed.

I tried many things like –

  1. Used the items virtualization feature and restrict the viewport
  2. Tried different rendering options for ScatterLineSeries.
  3. Kept minimum bindings
  4. Used ObservableCollection for binding datapoints
  5. Enabled caching

 

Can anyone please help me with this? What else can I try so that memory increasing will be restrict?

Dimitar
Telerik team
commented on 04 Dec 2023, 10:10 AM

Hi Renuka, 

Are you removing some points anywhere in your code as well? It seems that the application is adding points endlessly. After how much time are you receiving the exception? 

We have an example showing you can implement a similar live updated chart in our Demo application. Can you check it and see how it fits in your scenario?

 I am looking forward to your reply.

Renuka
Top achievements
Rank 1
commented on 13 Dec 2023, 05:26 AM

Can you please share a link for your Demo application in which you implement a similar live updated chart?
Dimitar
Telerik team
commented on 13 Dec 2023, 06:19 AM

Hi Renuka,

I do not have a link since the demo app is not a web application, it is a standalone WPF app that uses all of our controls. You can find more about it here: Installing WPF Demos application.

Let me know if you have additional questions.

No answers yet. Maybe you can help?

Tags
Chart
Asked by
Renuka
Top achievements
Rank 1
Share this question
or