views:

23

answers:

1

Hello,

Background:

I've been using the November 2009 release of the Silverlight Toolkit Charting components in a monitoring application that updates multiple line charts every 10 or so seconds.

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

Problem:

Memory just keeps going up and up. In WinDbg, I can see that the DataValuePair objects (even the ones that have been removed from the ObservableCollections) are still in the heap and are reference by the some elements of the charting component.

There are no other references to the objects in my application code, and the objects are removed from the ObservableCollections by a .Remove(item). I assume these would be deleted by the GC.

Can anyone see if I'm going wrong somewhere or is this a problem with the charting components?

Cheers! Chris

+1  A: 

Right, I've seem to have fixed this after two days trying!

Seems the memory leak was cause by styling on the LineDataPoints, which I've changed from this:

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

to this:

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

I.e., removing the Template setter that was previously set to null.

I'm not quite sure why this is but I will investigate.

Riddle