Possible memory leak in Silverlight Toolkit Charting - help!

Background:

I am using the November release of the Silverlight Toolkit Charting components in a monitoring application that updates several line charts every 10 or so seconds.

Each chart has a binding to an ObservableCollection. DataValuePair is a simple class containing only two properties (DateTime and int). Each time a DataValuePair is added to the collection, items that have passed a certain point in time are deleted (that is, there are always 50 DataValuePair objects in each collection).

Problem:

The memory just keeps growing. In WinDbg, I see that DataValuePair objects (even those that have been removed from ObservableCollections) are still on the heap and are links to some elements of the charting component.

There are no other object references in my application code, and objects are removed from ObservableCollections using .Remove (item). I assume that they will be removed by GC.

Can someone see if I am wrong somewhere or is it a problem with chart components?

Hooray! Chris

+3
source share
2 answers

That's right, I seem to have fixed it after two days of trying!

It seems that the memory leak was caused by the styles in LineDataPoints, which I changed from this:

<Style x:Key="SparklineDataPointStyle" TargetType="charting:LineDataPoint">
    <Setter Property="Template" Value="{x:Null}" />
    <Setter Property="Background" Value="LimeGreen" />
</Style>

:

<Style x:Key="SparklineDataPointStyle" TargetType="charting:LineDataPoint">
        <Setter Property="Background" Value="LimeGreen" />
</Style>

Ie by deleting the template template that was previously set to null.

I do not quite understand why this is so, but I will investigate.

+2
source

, ANTS Memory. , , WinDbg, . , .

+1

Source: https://habr.com/ru/post/1752669/


All Articles