I've noticed a memory leak when I add "RestrictInContainer = true" to my XamWebDialogWindows. Disabled, everything gets garbage collected as it should; enabled, though, the control appears to remain subscribed to some SizeChanged events:
0:022> !gcroot 07726064 Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 4 OSTHread 17a0Scan Thread 8 OSTHread 188cScan Thread 9 OSTHread 2c8Scan Thread 10 OSTHread 17b0DOMAIN(0CC4B488):HANDLE(Pinned):10712f8:Root: 0823d660(System.Object[])-> 072cbf70(System.Windows.Controls.Grid)-> 07787a18(System.Windows.SizeChangedEventHandler)-> 0773b1f0(System.Object[])-> 07730998(System.Windows.SizeChangedEventHandler)-> 07726064(StaffTrak.Silverlight.SilverlightMessageBox)
I tried setting RestrictInContainer to false before removing the dialog from the containing grid, but that doesn't seem to have any effect.
Can you verify this memory leak?
Hi,
Just to let you know that we released the service release that include the fix of this issueLet me know if you have any further questions.
Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.
We noticed the same issue in our application. We got around it by searching for an instance of our window in the Children collection property and calling the Show() method on it to re-use the window rather than create a new one.
private void button1_Click(object sender, RoutedEventArgs e)
{
XamDialogWindow window = null;
// if the window exists don't create a new one
foreach (UIElement elem in grid1.Children)
if (elem.GetType() == typeof(XamDialogWindow))
window = elem as XamDialogWindow;
if (window != null)
window.Show();
}
if (window == null)
// it doesn't exist so create a new one
window = new XamDialogWindow();
window.Content = "MyWindow";
grid1.Children.Add(window);
window.Maximize();
window.RestrictInContainer = true;
Hello,
Thank you for the detailed clarifications. I think that this is a issue and we need to look at it. I have created case (CAS-45490-02YYYW) for you and I will forward this behavior to our development team.
I will contact you in the support case for more information.
I'm using the Silverlight 10.1 Service Release, which appears to be the latest.
I use WinDbg to check whether an object can be garbage collected. I have attached a simple project and will walk through my steps:
If you set "RestrictInContainer = true", then the !gcroot looks like:
DOMAIN(05DD9840):HANDLE(Pinned):23212f8:Root: 07d29260(System.Object[])-> 06d687d8(Infragistics.Silverlight.DialogManager)->
06d68b70(System.Collections.Generic.Dictionary`2[[System.Windows.FrameworkElement, System.Windows],[Infragistics.Silverlight.WeakList`1[[Infragistics.Silverlight.Controls.XamWebDialogWindow, Infragistics.Silverlight.XamWebDialogWindow.v10.1]], Infragistics.Silverlight.v10.1]])->
06d75608(System.Collections.Generic.Dictionary`2+Entry[[System.Windows.FrameworkElement, System.Windows],[Infragistics.Silverlight.WeakList`1[[Infragistics.Silverlight.Controls.XamWebDialogWindow, Infragistics.Silverlight.XamWebDialogWindow.v10.1]], Infragistics.Silverlight.v10.1]][])->
06d64324(System.Windows.Controls.Grid)->
06d823dc(System.Windows.SizeChangedEventHandler)->
06d823c4(System.Object[])->
06d823a4(System.Windows.SizeChangedEventHandler)->
06d79740(Infragistics.Silverlight.Controls.XamWebDialogWindow)
Note the additional SizeChangedEventHandlers that are referenced. This was what caused me to open this thread, but then I noticed that even without RestrictInContainer, the XamWebDialogWindows will never be garbage collected.
Hope this helps to clarify my findings.
Hello Jason, I was tried to reproduce this issue but the memory was down after I closed all of the dialogs. I have test this with VS performance tools, can you tell me how you test this behavior? Please make sure that you are using the latest service release. Also I am recommending you to create new instance in the function you need to show WebDialogWindow in this way the dialog memory will be released after you closed it, otherwise the memory will be released after the parent page is closed and getting disposed.If you still has issue with this, would you mind id you share small sample to investigate it more deeply.I hope this helps.Sincerely,DimiDeveloper Support EngineerInfragistics, Inc.