开发者

Silverlight DataForm Memory Leak

Some Background

I have noticed that setting the EditTemplate of a DataForm (from the Silverlight Toolkit) can cause the DataForm to not be garbage collected. Consequently, the parent control of the DataForm c开发者_运维知识库annot be garbage collected either, causing a very significant memory leak.

Here's some XAML which demonstrates the case.

    <toolkit:DataForm HorizontalAlignment="Stretch" Margin="10" VerticalAlignment="Stretch">
        <toolkit:DataForm.EditTemplate>
            <DataTemplate>
                <toolkit:DataField Label="Dummy Binding:">
                    <TextBox Text="{Binding DummyBinding, Mode=TwoWay}" />
                </toolkit:DataField>
            </DataTemplate>
        </toolkit:DataForm.EditTemplate>
    </toolkit:DataForm>

I have opened an issue on CodePlex. The isssue has an attachment which has a project which desmonstrates the case.

So, My Question Is

Has anyone else encountered this issue? More importantly, does anyone know of any workarounds? How can I force this DataForm to be garbage collected?


FYI, to anyone concerned about this issue... MS released a fix for this.

Silverlight 4 Service Release


It turns out that this issue is not specific to the DataForm control, and that it is actually a problem with the Silverlight 4 runtime. All built-in controls and user controls that use a DataTemplate have this issue as discussed in greater detail in this thread. Tim Heuer (the Silverlight Program Manager) is responsive on the thread and proposes a possible workaround with mixed results. He does mention that they already have a fix entered into testing, so hopefully an update should be released relatively soon.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜