CompositionTarget.Rendering leak?

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

anomistu wrote at 2012-04-19 16:08:

Hi,

I think I've stumbled upon a memory leak when dynamically generating plots. Imagine something like this:

<ItemsControl ItemsSource="{Binding}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Vertical" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <oxy:Plot Model="{Binding}" Height="300"/>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>


Even though the context changes, "old" plots remain hooked and, after profiling, I'm pretty sure the CompositionTarget.Rendering event is the culprit.

I eagerly await your comments on this.

Thank you


objo wrote at 2012-04-19 21:29:

thanks for the notice, I have planned to do some memory profiling, will try to get it done soon.

I have implemented a weak event manager for the rendering event in the helix toolkit, this should be possible to use.


anomistu wrote at 2012-04-20 14:14:

I saw that you've had a similar problem on the helix project, however the weak event manager you've used over there is not available in SL.

Another problem is that in SL the CompositionTarget class is static, not abstract, as in WPF, so it can't be used as an argument to most weak event listeners available out there that use generics when subscribing.

Сервис поддержки клиентов работает на платформе UserEcho