Resolving a Silverlight ChildWindow Memory Leak

Does anyone know how to resolve memory leak in SL3 using ChildWindow?

See the code snippet below:

 private void Button_Click(object sender, RoutedEventArgs e)
    {
        var window = new ChildWindow();

        window.Closed += new EventHandler(window_Closed);

        window.Show();
    }

    void window_Closed(object sender, EventArgs e)
    {
        ((ChildWindow)sender).Closed -= new EventHandler(window_Closed);

        WeakReference reference = new WeakReference(sender);

        GC.Collect();

        GC.WaitForPendingFinalizers();

        bool isControlAlive = a.IsAlive;
    }

It always shows up as “live” - and when I control the iexplore instance in the task manager, the memory continues to increase every time I open and close the child window.

Please, help.

Thank.

Chris

+3
source share
1 answer

There is no official correction yet, as far as I know. This page describes the nature of a memory leak:

... [ChildWindow] RootVisual_GotFocus, . , ChildWindow , GotFocus RootVisual.

Silverlight Toolkit , :

ChildWindow_LostFocus ChildWindow.cs( 731), RootVisual_GotFocus :

Application.Current.RootVisual.GotFocus -= this.RootVisual_GotFocus;
Application.Current.RootVisual.GotFocus += this.RootVisual_GotFocus;
+4

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


All Articles