System.AccessViolationException: 'Attempted to read or write protected memory.

Hi, im using the chart control in combination with FastCandleBitmapSeries with around 8000 candles, around a 100 step line series and around a 100 text annotations with custom templates. The chart loads alright and resizing works albeit a bit slow. Now the problem arises when i first zoom in and then start moving around, After a few moves the following error pops up and halts the app.

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

Ive run windows memory diagnostics but they came up empty.


Im using the latest version i could find which is 20.2.0.45


any ideas on how i can fix/ work around this?


3 Replies

TH thomas August 23, 2022 12:20 PM UTC


When i disable the text annotations the problem is gone.


private void UpdateTrades()

    {

      Chart.Annotations.Clear();

      if (BarData == null || BarData.Count() == 0 || Trades == null)

      {

        return;

      }


      foreach (var trade in Trades)

      {

        var text = new TextAnnotation();

        text.X1 = trade.When;


        if (trade.Volume > 0)

        {

          text.Y1 = GetBar(trade.When)?.HighPrice + 5;

          text.ContentTemplate = Grid.Resources["buy"] as DataTemplate;

        }

        else

        {

          text.Y1 = GetBar(trade.When)?.LowPrice - 1;

          text.ContentTemplate = Grid.Resources["sell"] as DataTemplate;

        }


        Chart.Annotations.Add(text);

      }

    }


with


 <Grid.Resources>

            <DataTemplate x:Key="sell">

                <StackPanel>

                    <TextBlock Text="Sell" Margin="-10,0,0,10" HorizontalAlignment="Center"/>

                    <Polygon Points="-10,10,10,10,0,0" Fill="Red"/>

                </StackPanel>

            </DataTemplate>


            <DataTemplate x:Key="buy">

                <StackPanel>

                    <Polygon Points="-10,10,10,10,0,20" Fill="Green"/>

                    <TextBlock Text="Buy" Margin="-10,0,0,10" HorizontalAlignment="Center"/>

                </StackPanel>

            </DataTemplate>

        </Grid.Resources>


any ideas  what can cause this? When i load only 2 annotations then there is no problem



DD Devakumar Dhanapoosanam Syncfusion Team August 24, 2022 10:56 PM UTC

Hi Thomas,


We will validate and update the complete details in two business days on or before August 26, 2022.


Regards,

Devakumar D



DD Devakumar Dhanapoosanam Syncfusion Team August 26, 2022 02:33 AM UTC

Hi Thomas,


We have checked with FastCandleBitmapSeries and adding multiple annotations based on the provided details and while zooming we were unable to reproduce the reported issue. Please find the tested sample in the attachment below.


We would like to suggest FastStepLineBitmapSeries instead of step line series to improve performance and set the annotation collection direct instead of adding each using add method as per in the below code example.


Chart.Annotations.Clear();

AnnotationCollection annotations = new AnnotationCollection();

 

foreach (var trade in Trades)

{

    var text = new TextAnnotation();

   

    annotations.Add(text);

}

 

Chart.Annotations = annotations;


https://help.syncfusion.com/wpf/charts/fastchart/fast-bitmapseries#fast-step-line-bitmap


If you still face any problem, could you please revert us by modifying the sample with issue reproduced state and replication steps which will be helpful to provide you better solution at the earliest.


Regards,

Devakumar D


Attachment: SF_176989_cf42b3f6.zip

Loader.
Up arrow icon