1
votes

I've been getting memory leaks in Silverlight because of the UI automation framework as documented here

We implement custom control libraries (controls which inherit basic Silverlight controls and extend their functionality). e.g.

<local:BaseControl x:Name="DropDownControl" x:Class="xxx.xxx.Views.DropDown"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local ="clr-namespace:xxx.CustomControls.Views"  
mc:Ignorable="d"

d:DesignHeight="23" d:DesignWidth="120" Background="#FF1F3B53">
<Border x:Name="bdrMain" BorderThickness="1" BorderBrush="Transparent">
    <Grid x:Name="LayoutRoot">
        <ComboBox x:Name="ddlMainControl" Canvas.ZIndex="1"/>
    </Grid>
</Border>

I can disable automation for the Custom Control itself by overriding the OnCreateAutomationPeer method in the class itself.

protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
{
   return null;
}

However, the Combobox iteself must still respond to requests from the Automation Provider for its Automation Peer as I can still see it leaking in WinDBG. Any ideas on how to disable Automation for the Combobox in this scenario?

P.S. - I know you disable automation application wide by setting the windowless param = true but it's a mature application and I'd prefer not to change anything application wide that might add risk

1

1 Answers

0
votes

The default panel is the VirtualisingStackPanel which may be the cause of your problem.