WinDbg output

Topics: Prism v4 - Silverlight 4
Nov 21, 2011 at 1:24 AM

In my SL5, Prism 4 app, I am having a memory leak issue. I am using Pod control (a usercontrol) based layout, as shown in the link below:

Now when I remove a Pod control from its container, it doesn't get removed from memory. I take special care to unsubscribe events associated to the control.

Then I used WinDbg to debug the issue. Can someone please have a look at the WinDbg output and suggest me where is the leak happening (especially in the GCRoot output)?

Thanks a lot in advance,




0:003> !dumpheap -stat -type BSA.CMS.UI.Silverlight
      MT    Count    TotalSize Class Name
03e04724        1           12 System.Collections.Generic.ObjectEqualityComparer`1[[BSA.CMS.UI.Silverlight.Common.Base.PodControl, BSA.CMS.UI.Silverlight]]
79594ed0        1           16 System.Object[]
03e0b174        1           16 BSA.CMS.UI.Silverlight.Common.Events.ViewNavigatedEvent
03e07f14        1           16 BSA.CMS.UI.Silverlight.Modules.TopMenu.View.TopMenuView+<>c__DisplayClass2
03e07a3c        1           16 BSA.CMS.UI.Silverlight.Common.Events.LoadEntityEvent
03e0561c        1           16 BSA.CMS.UI.Silverlight.Common.Events.ClearARegionEvent
03e05580        1           16 BSA.CMS.UI.Silverlight.Common.Events.ClearViewFromRegionEvent
03e051f8        1           16 BSA.CMS.UI.Silverlight.Common.Events.LoadViewInRegionEvent
03e03418        1           16 BSA.CMS.UI.Silverlight.Common.Base.ViewNavigationHandler
009c12a4        1           16 BSA.CMS.UI.Silverlight.Modules.AccordionMenu.View.ParticipantMenuView+<>c__DisplayClass2
03e07e50        1           20 Microsoft.Practices.Prism.Events.EventSubscription`1[[BSA.CMS.UI.Silverlight.Common.Base.EntityDetailsHolder, BSA.CMS.UI.Silverlight]]
038b61b8        2           24 BSA.CMS.UI.Silverlight.Common.Base.Pod.Controls.GridSplitterCollapseMode
03e0b668        1           32 BSA.CMS.UI.Silverlight.Common.Base.PodControl+RequestingAction
03e07dc0        1           32 System.Predicate`1[[BSA.CMS.UI.Silverlight.Common.Base.EntityDetailsHolder, BSA.CMS.UI.Silverlight]]
03e07c80        1           32 System.Action`1[[BSA.CMS.UI.Silverlight.Common.Base.EntityDetailsHolder, BSA.CMS.UI.Silverlight]]
03e06bb4        1           32 System.Predicate`1[[BSA.CMS.UI.Silverlight.Common.Base.NavigationDetailsHolder, BSA.CMS.UI.Silverlight]]
03c6cd00        1           32 BSA.CMS.UI.Silverlight.Bootstrapper
03e079c0        2           40 BSA.CMS.UI.Silverlight.Common.Base.PodLoader
03e03e34        2           48 System.Collections.Generic.List`1[[BSA.CMS.UI.Silverlight.Common.Base.PodControl, BSA.CMS.UI.Silverlight]]
009c1cc0        3           48 BSA.CMS.UI.Silverlight.Common.Commands.RadioButtonCommand+CommandRadioButtonBehavior
03e042c4        1           52 System.Collections.Generic.Dictionary`2[[BSA.CMS.UI.Silverlight.Common.Base.PodControl, BSA.CMS.UI.Silverlight],[BSA.CMS.UI.Silverlight.Common.Base.Pod.MinimizedPod, BSA.CMS.UI.Silverlight]]
038b4d9c        1           56 BSA.CMS.UI.Silverlight.App
03e07908        1           60 BSA.CMS.UI.Silverlight.Modules.TopMenu.ViewModel.TopMenuViewModel
009c11f4        1           60 BSA.CMS.UI.Silverlight.Modules.AccordionMenu.ViewModel.ParticipantMenuViewModel
03e0579c        2           64 System.Action`1[[BSA.CMS.UI.Silverlight.Common.Base.NavigationDetailsHolder, BSA.CMS.UI.Silverlight]]
03e06c44        4           80 Microsoft.Practices.Prism.Events.EventSubscription`1[[BSA.CMS.UI.Silverlight.Common.Base.NavigationDetailsHolder, BSA.CMS.UI.Silverlight]]
03e03a4c        1          104 BSA.CMS.UI.Silverlight.Shell
03dbcc00        1          104 BSA.CMS.UI.Silverlight.CoreShell
03e073b4        1          116 BSA.CMS.UI.Silverlight.Modules.TopMenu.View.TopMenuView
03e03cd4        1          180 BSA.CMS.UI.Silverlight.Common.Base.Pod.PodContainer
038b6040        1          184 BSA.CMS.UI.Silverlight.Common.Base.Pod.Controls.ExtendedGridSplitter
03dbcf70        1          192 BSA.CMS.UI.Silverlight.Common.Base.PodControl
03e08a70        1          368 BSA.CMS.UI.Silverlight.Modules.AccordionMenu.View.ParticipantMenuView
Total 42 objects

0:003> !dumpheap -MT 03dbcf70
 Address       MT     Size
06169264 03dbcf70      192    

      MT    Count    TotalSize Class Name
03dbcf70        1          192 BSA.CMS.UI.Silverlight.Common.Base.PodControl
Total 1 objects

0:003> !gcroot 06169264
    030f11f8 (pinned handle)
    -> 07054220 System.Object[]
    -> 06069d20 BSA.CMS.UI.Silverlight.App
    -> 06103dc0 BSA.CMS.UI.Silverlight.CoreShell
    -> 0610e5dc System.Collections.Generic.Dictionary`2[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValueEntry
    -> 0610e628 System.Collections.Generic.Dictionary`2+Entry[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValu
    -> 0610e594 Microsoft.Practices.Prism.Regions.RegionManager
    -> 0610e5a0 Microsoft.Practices.Prism.Regions.RegionManager+RegionCollection
    -> 0610e5b4 System.Collections.Generic.List`1[[Microsoft.Practices.Prism.Regions.IRegion, Microsoft.Practices.Prism]]
    -> 06173dd4 System.Object[]
    -> 06173730 Microsoft.Practices.Prism.Regions.AllActiveRegion
    -> 06173d54 System.ComponentModel.PropertyChangedEventHandler
    -> 06173d3c System.Object[]
    -> 06173d1c System.ComponentModel.PropertyChangedEventHandler
    -> 06173b08 Microsoft.Practices.Prism.Regions.Behaviors.SyncRegionContextWithHostBehavior
    -> 0616cde0 System.Windows.Controls.ItemsControl
    -> 0619ab24 System.Windows.Controls.ScrollContentPresenter
    -> 0619ac14 System.Windows.Controls.Grid
    -> 0619ac7c System.Collections.Generic.Dictionary`2[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]]
    -> 0619acc8 System.Collections.Generic.Dictionary`2+Entry[[MS.Internal.IManagedPeerBase, System.Windows],[System.Object, mscorlib]][]
    -> 0619ad14 System.Windows.Controls.Primitives.ScrollBar
    -> 0619b08c System.Collections.Generic.Dictionary`2[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValueEntry
    -> 0619b1e8 System.Collections.Generic.Dictionary`2+Entry[[System.Windows.DependencyProperty, System.Windows],[System.Windows.EffectiveValu
    -> 0619b074 MS.Internal.ModifiedValue
    -> 0619afa8 System.Windows.TemplateBindingExpressionForCore
    -> 0616caa0 System.Windows.Controls.ScrollViewer
    -> 0616cfdc System.Windows.Controls.Border
    -> 0616d0dc System.Windows.Controls.Grid
    -> 0616e0cc System.Windows.Controls.Grid
    -> 0616be04 System.Windows.Controls.Grid
    -> 06169264 BSA.CMS.UI.Silverlight.Common.Base.PodControl

Nov 21, 2011 at 3:21 PM


So far we couldn't find the source of the memory leak you are experiencing with the information you provided. Therefore It would be helpful if you could provide us with a repro sample application that portrays that problem, so we can help you find the cause and a possible solution for your issue.


Agustin Adami

Nov 21, 2011 at 9:38 PM

Hi aadami,

I have sent link to my project to your email id.

Thanks a lot,


Nov 22, 2011 at 9:18 PM

Hi Dharmesh,

We have analyzed you sample and so far we found that, if the ContentRegionName property of a PodControl is not set (in the LoadNewPod method of the PodLoader class), this memory leak does not appear. Based on this and on my own understanding, the reason behind the memory leak might be that the RegionManager is holding a reference to each new PodControl. When the ContentRegionName property is set, the PodControl is registered as a region in the RegionManager. However, when the PodControl is closed, this registration is never undone so the RegionManager keeps holding a reference and the PodControl is never disposed. To solve this, you could remove the PodControl registration from the RegionManager using the following code in the Pod_CloseChanged method of the PodContainer class:

var regionManager = RegionManager.GetRegionManager(p);


I hope you find this useful,

Damian Cherubini

Nov 22, 2011 at 10:49 PM

Thanks Damian for your help. I appreciate it a lot.

However I still can't get the PodControl to clear out of memory (after using the code above). I am using WinDbg to do my debugging.

I did the following:


            var regionManager = RegionManager.GetRegionManager(p);
            if (p.AccordionMenuRegionName != string.Empty)



I tried placing this bit in both Pod_CloseChanged and CleanUpPod functions at different places.

Million thanks again for all your help.


Nov 23, 2011 at 12:56 AM
Edited Nov 23, 2011 at 1:01 AM


Along with implementing your suggestion Damian, I also checked few other things. I was saving reference of the podcontrol in _maximizedPod and _draggedPod in PodLoader. I cleared it and things work fine for me now.

Thanks again to you Damian, Agustin and other Prism team members to help me out with my issues.