Silverlight ChildWindow Memory Leak -


Does anyone know how to solve memory leaks in SL3 with child windows?

Code snippet below:

  Private zero button button (object sender, routing event e) {var window = new child window}; Window.Closed + = new event heredollar (window_Closed); Window.Show (); } Zero window_Closed (Object Sender, EventArgs e) {(ChildWindow) Sender). Off - = new event heredollar (window_Closed); WeakReference Reference = New WeakReference (Sender); GC.Collect (); GC.WaitForPendingFinalizers (); Bool is; ControlAlive = a.IsAlive; }  

It is always visible as "alive" - ​​and when I monitor the example example in the task manager - memory every time I open and close the hair window gives.

Please help.

Thank you.

Chris

There is no official fix yet as far as I know is. Description of the nature of the memory leak:

... [ChildWindow] subscribes to RootVisual_GotFocus several times, but it only terminates it once during closeup. This requires ChildWindow to remain permanently in the memory related to the GotFocus incident of RootViewual.

According to the comment section, you can modify the Silverlight Toolkit code to fix this problem:

RootVisual_GotFocus again by linking the listener First modify the ChildWindow_LostFocus function at ChildWindow.cs (line 731):

  Application.Current.RootVisual.GotFocus - = this.RootVisual_GotFocus; Application Present. RootVijual.GotFocus + = this.RootVisual_GotFocus;  

Comments