Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
Memory leak when using RestrictInContainer
posted

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" for
more info.
Scan Thread 4 OSTHread 17a0
Scan Thread 8 OSTHread 188c
Scan Thread 9 OSTHread 2c8
Scan Thread 10 OSTHread 17b0
DOMAIN(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?

Parents Reply
  • 155
    posted in reply to [Infragistics] Dimi Gineva

    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:

    • Open the site in IE (not through the VS debugger), click to open and close a XamWebDialogWindow or two, then attach WinDbg to the iexplore process.
    • Execute ".loadby sos coreclr" to load the Silverlight SOS dll.
      • If this fails, you may have attached to the wrong iexplore process, try another one.
    • Execute "!dumpheap -type XamWebDialogWindow"
      • Unfortunately this is a substring search so we have to find the MT for Infragistics.Silverlight.Controls.XamWebDialogWindow, in my case 0220789c.
    • Execute "!dumpheap -mt 0220789c". This shows you all instances of XamWebDialogWindow. Get the address of one of the instances, in my case 06d67418.
    • Execute "!gcroot 06d67418". In my case, it displays:
      • DOMAIN(04AFC010):HANDLE(Pinned):23012f8:Root:  07d24250(System.Object[])->
          06d5ca88(System.Collections.Generic.List`1[[System.Object, mscorlib]])->
          06d88e84(System.Object[])->
          06d67418(Infragistics.Silverlight.Controls.XamWebDialogWindow)
      • This shows that the window is still referenced in a few different locations and will NOT be garbage collected.

     

    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.

Children