We discovered a memory leak when attaching a KeyBinding to a PasswordBox and passing the PasswordBox as the CommandParameter. We could resolve this by moving the InputBinding up in the element hierarchy, however ideally this should not happen.
The XAML causing the leak
<PasswordBox
x:Name="PasswordBox"
Width="300"
Margin="0,24,0,0"
>
<PasswordBox.InputBindings>
<KeyBinding Key="Return" Command="{Binding SubmitPasswordCommand}" CommandParameter="{Binding ElementName=PasswordBox}" />
</PasswordBox.InputBindings>
</PasswordBox>
The fix:
<StackPanel Margin="20" VerticalAlignment="Center">
<StackPanel.InputBindings>
<KeyBinding Key="Return" Command="{Binding SubmitPasswordCommand}" CommandParameter="{Binding ElementName=PasswordBox}" />
</StackPanel.InputBindings>
<PasswordBox
x:Name="PasswordBox"
Width="300"
Margin="0,24,0,0"
/>
</StackPanel>
The memory leak report:
2026-03-31 10:05:12.1348|INFO|Noesis|: Noesis Shutdown
2026-03-31 10:05:12.1377|INFO|Noesis|: --------------------------------------------------------
2026-03-31 10:05:12.1377|INFO|Noesis|: Alive Objects Report
2026-03-31 10:05:12.1386|INFO|Noesis|: Class Name Instance Count
2026-03-31 10:05:12.1386|INFO|Noesis|: --------------------------------------------------------
2026-03-31 10:05:12.1395|INFO|Noesis|: Setter 35
2026-03-31 10:05:12.1395|INFO|Noesis|: DynamicResourceExpression 26
2026-03-31 10:05:12.1404|INFO|Noesis|: BaseSetterCollection 13
2026-03-31 10:05:12.1404|INFO|Noesis|: SolidColorBrush 10
2026-03-31 10:05:12.1404|INFO|Noesis|: BaseComponent 10
2026-03-31 10:05:12.1417|INFO|Noesis|: Binding 9
2026-03-31 10:05:12.1417|INFO|Noesis|: BindingExpression 9
2026-03-31 10:05:12.1425|INFO|Noesis|: PropertyPath 8
2026-03-31 10:05:12.1425|INFO|Noesis|: Trigger 8
2026-03-31 10:05:12.1432|INFO|Noesis|: Style 6
2026-03-31 10:05:12.1432|INFO|Noesis|: TemplateBindingExpression 5
2026-03-31 10:05:12.1432|INFO|Noesis|: TemplateBinding 5
2026-03-31 10:05:12.1444|INFO|Noesis|: Border 4
2026-03-31 10:05:12.1444|INFO|Noesis|: ControlTemplate 3
2026-03-31 10:05:12.1454|INFO|Noesis|: BaseTriggerCollection 3
2026-03-31 10:05:12.1454|INFO|Noesis|: Grid 2
2026-03-31 10:05:12.1454|INFO|Noesis|: Boxed<Bool> 2
2026-03-31 10:05:12.1466|INFO|Noesis|: UIElementCollection 2
2026-03-31 10:05:12.1466|INFO|Noesis|: Cursor 2
2026-03-31 10:05:12.1474|INFO|Noesis|: Boxed<VerticalAlignment> 2
2026-03-31 10:05:12.1474|INFO|Noesis|: RelativeSource 2
2026-03-31 10:05:12.1483|INFO|Noesis|: Boxed<Visibility> 2
2026-03-31 10:05:12.1483|INFO|Noesis|: Adorner 2
2026-03-31 10:05:12.1483|INFO|Noesis|: Boxed<Single> 2
2026-03-31 10:05:12.1495|INFO|Noesis|: TextBlock 1
2026-03-31 10:05:12.1495|INFO|Noesis|: Boxed<UInt32> 1
2026-03-31 10:05:12.1504|INFO|Noesis|: MeshData 1
2026-03-31 10:05:12.1504|INFO|Noesis|: Image 1
2026-03-31 10:05:12.1504|INFO|Noesis|: TextBoxView 1
2026-03-31 10:05:12.1516|INFO|Noesis|: Boxed<KeyboardNavigationMode> 1
2026-03-31 10:05:12.1516|INFO|Noesis|: BitmapImage 1
2026-03-31 10:05:12.1524|INFO|Noesis|: KeyGesture 1
2026-03-31 10:05:12.1524|INFO|Noesis|: PasswordBox 1
2026-03-31 10:05:12.1533|INFO|Noesis|: InputBindingCollection 1
2026-03-31 10:05:12.1533|INFO|Noesis|: BaseObject 1
2026-03-31 10:05:12.1533|INFO|Noesis|: FontFamily 1
2026-03-31 10:05:12.1545|INFO|Noesis|: ScrollViewer 1
2026-03-31 10:05:12.1545|INFO|Noesis|: Boxed<HorizontalAlignment> 1
2026-03-31 10:05:12.1554|INFO|Noesis|: KeyBinding 1
2026-03-31 10:05:12.1554|INFO|Noesis|: Boxed<Thickness> 1
2026-03-31 10:05:12.1562|INFO|Noesis|: NameScope 1
2026-03-31 10:05:12.1562|INFO|Noesis|: --------------------------------------------------------
2026-03-31 10:05:12.1573|WARN|Noesis|: Memory leaks detected: 53712 bytes
|