You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create a UserControl, with an empty ComboBox () then use that UserControl in a TabItem of a TabControl, the UserControl is not beeing reclaimed by the GC after you Remove the TabItem.
Reproduction Steps
Create UserControl with ComboBox
Create TabControl in for example MainWindow
Add TabItem with UserControl as Content.
Remove the TabItem. (UserControl is not beeing reclaimed by GC)
Expected behavior
UserControl should be collected by GC.
Actual behavior
UserControl with a ComboBox is not getting garbage collected after removing TabItems from a TabControl, due to a handler set by the ItemContainerGenerator of the ComboBox (ItemContainerGenerator EventHandler).
Regression?
No response
Known Workarounds
No response
Impact
The severity of the leak of course depends on the UserControl.
@D-Bracket Using your repro, there's no memory leak. As you can see, I'm on tab item 25 and the previous ones have been collected.
First screenshot is triggering the collection early while always keeping 1 tab item, second is spawning about 40 of them, then removing them and waiting for GC to happen naturally.
Description
If you create a UserControl, with an empty ComboBox () then use that UserControl in a TabItem of a TabControl, the UserControl is not beeing reclaimed by the GC after you Remove the TabItem.
Reproduction Steps
Expected behavior
UserControl should be collected by GC.
Actual behavior
UserControl with a ComboBox is not getting garbage collected after removing TabItems from a TabControl, due to a handler set by the ItemContainerGenerator of the ComboBox (ItemContainerGenerator EventHandler).
Regression?
No response
Known Workarounds
No response
Impact
The severity of the leak of course depends on the UserControl.
Configuration
OS: Windows 10/11
.NET Version: .NET8
Visual Studio: VS2022
Architecture: x64
Other information
Minimal repro:
I have built repository showcasing the issue:
https://github.com/D-Bracket/WPF.MemoryLeak.Tests
The text was updated successfully, but these errors were encountered: