I have a UserControl in an application where I am constantly swapping the Content property with other UIElements.
However I noticed in Task Manage after a while the memory goes up after a number of swaps...
Using AntProfiler I noticed for some reason there ToolBarAutomationPeer that the UserControl references....
To fix this Memory leak I made my own usercontrol with the following code
public class MyUserControl : UserControl
{
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
return null;
}
}
This seems to remove any AutomationPeers that THe usercontrol may reference that may keep the Content that I am swapping in memory...
But I am still interested to know how did a ToolBarAutomationPeer get into my UserControl and what are the ramifications of me returning null in the OnCreateAutomationPeer method?
I am not well versed with Automation callses and not sure when they would be useful
Thanks