Repository: dotnet/winforms

Issue #7385: ListView accessible objects are leaking in memory
Created: 2022-07-07T14:38:18Z
.NET version
7.0 Preview 6
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
ListView accessible objects are left in memory after the ListView control instance with its items was inspected with accessibility tool (like Accessibility Insights or Inspect) and the form with ListView is closed, garbage is collected, but accessibility tool is still opened.
WinDbg snapshot after disposing:

Steps to reproduce

Create a parent form with two buttons: one will be opening a child form with the ListView control and the other will collect the garbage.
Press the second button to open the child form with ListView.
Start the Accessibility Insights tools or Inspect.
Run automated checks for the ListView control using AI/Inspect.
Close the child form.
Clear memory with the first button of the parent form.
DON'T close the AI/Inspect tool.
Look for ListView objects left in memory (using WinDbg, or dotMemory, or another suitable tool).

Duplicate issue #7329: Control classes leaking memory
Created: 2022-06-21T14:24:39Z
.NET version
.NET 7.0 Preview 4
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
Investigating possible memory leaks with Windows Forms classes inherited to Control class AND in corresponding Accessible Objects.
Some control items and some accessible objects are left in memory after the control instance with its items was inspected with accessibility tool (like Accessibility Insights or Inspect) and the form with the control is closed, garbage is collected, but accessibility tool is still opened.
Abstract, private and internal control classes which can't be placed in a form Controls collection are not applicable.
Control classes from the namespace System.Windows.Forms.Design are not not applicable.
Table 1. Control classes tested for memory leaks:











Class   name
Base class name
Memory leaks
Issue assigned
Status




DataGridView
Control
Is leaking
#7347
Fixed


PropertyGrid
ContainerControl
Is leaking
#6943
Fixed


DomainUpDown
UpDownBase
Is leaking
#7328
Fixed


ToolStrip
ScrollableControl
Is leaking
#7375
Fixed


ListBox
ListControl
Is leaking
#7197
Fixed


ListView
Control
Is leaking
#7385
Fixed


CheckedListBox
ListBox
Is leaking
#7197
Fixed


ComboBox
ListControl
Is leaking
#7318
Fixed


TextBox
TextBoxBase
Is leaking
#7248
Fixed


TreeView
Control
Is leaking
#7196
Fixed


MonthCalendar
Control
Is leaking
#6852
Fixed


NumericUpDown
UpDownBase
Is leaking
#7328
Fixed


TabPage
Panel
Is leaking (when   tested with Narrator)
#7415
Fixed


LinkLabel
Label
Is leaking
 #9327
Fixed


Button
ButtonBase
Is not leaking
 



CheckBox
ButtonBase
Is not leaking
 



RadioButton
ButtonBase
Is not leaking
 



DateTimePicker
Control
Is not leaking
 



GroupBox
Control
Is not leaking
 



ThreadExceptionDialog
Form
Is not leaking
 



UpDownBase
ContainerControl
Is not leaking
 



SplitterPanel
Panel
Is not leaking
 



BindingNavigator
ToolStrip
Is not leaking




MenuStrip
ToolStrip
Is not leaking
 



StatusStrip
ToolStrip
Is not leaking
 



ContextMenuStrip
ToolStripDropDownMenu
Is not leaking
 



ToolStripOverflow
ToolStripDropDown
Is not leaking
 



HScrollBar
ScrollBar
Is not leaking
 



VScrollBar
ScrollBar
Is not leaking
 



Label
Control
Is not leaking
 



ProgressBar
Control
Is not leaking
 



RichTextBox
TextBoxBase
Is not leaking




MaskedTextBox
TextBoxBase
Is not leaking
 



TabControl
Control
Is not leaking
 



TrackBar
Control
Is not leaking
 



DataGridViewTextBoxEditingControl
TextBox
Is not leaking
 



PrintPreviewControl
Control
Is not leaking
 



ToolStripPanel
ContainerControl
Is not leaking
 



SplitContainer
ContainerControl
Is not leaking
 



ToolStripContainer
ContainerControl
Is not leaking
 



Panel
ScrollableControl
Is not leaking
 



TableLayoutPanel
Panel
Is not leaking
 



ToolStripContentPanel
Panel
Is not leaking
 



DataGridViewComboBoxEditingControl
ComboBox
Is not leaking
 



PictureBox
Control
Is not leaking
 



ColorEditorTabControl
TabControl
Is not leaking




Splitter
Control
Is not leaking




WebBrowser
WebBrowserBase
Is not leaking

Deprecated 





Table 2. Control classes that are not applicable on the form:











Class   name
Base class name




Control
 


AdornerWindow
Control


AnchorUI
Control


AxHost
Control


ButtonBase
Control


DetailsButton
Button


DropDownButton
Button


EditorButton
Button


SplitButton
Button


DockEditorCheckBox
CheckBox


ColorPalette
Control


ColorUI
Control


ContainerPlaceholder
Control


ContentUI
Control


ControlPlaceholder
Control


DateTimeUI
Control


DesignerFrame
Control


DockUI
Control


GridToolTip
Control


SelectionUIService
Control


ScrollableControl
Control


ComponentTray
ScrollableControl


ContainerControl
ScrollableControl


DesignerActionPanel
ContainerControl


BinaryUI
Form


CollectionForm
Form


CollectionEditorCollectionForm
CollectionForm


StringCollectionForm
CollectionForm


ComponentEditorForm
Form


DataGridViewCellStyleBuilder
Form


DropDownHolder
Form


FormatStringDialog
Form


FlyoutDialog
Form


DropDownHolder
FlyoutDialog


GridErrorDialog
Form


PrintPreviewDialog
Form


StatusDialog
Form


LinkAreaUI
Form


MaskDesignerDialog
Form


MdiWindowDialog
Form


ParkingWindow
ContainerControl


ToolStripNumericUpDownControl
NumericUpDown


UserControl
ContainerControl


BorderSidesEditorUI
UserControl


FormatControl
UserControl


ShortcutKeysUI
UserControl


MaskedTextBoxTextEditorDropDown
UserControl


OverlayControl
ScrollableControl


ComponentEditorPage
Panel


DataGridViewEditingPanel
Panel


FlowLayoutPanel
Panel


ByteViewer
TableLayoutPanel


ToolStripEditorControl
Panel


PropertyGridToolStrip
ToolStrip


MdiControlStrip
MenuStrip


MdiWindowListStrip
MenuStrip


ToolStripDropDown
ToolStrip


DesignerActionToolStripDropDown
ToolStripDropDown


FeedbackDropDown
ToolStripDropDown


ToolStripDropDownMenu
ToolStripDropDown


GroupedContextMenuStrip
ContextMenuStrip


BaseContextMenuStrip
GroupedContextMenuStrip


NewItemsContextMenuStrip
GroupedContextMenuStrip


TransparentToolStrip
ToolStrip


ScrollBar
Control


SKWindow
Control


SpringControl
Control


EditorLabel
Label


MethodItemLinkLabel
LinkLabel


StickyLabel
Label


ListControl
Control


ColorEditorListBox
ListBox


CursorUI
ListBox


GridViewListBox
ListBox


FilterListBox
ListBox


ToolStripComboBoxControl
ComboBox


MarshalingControl
Control


MdiClient
Control


DateTimeMonthCalendar
MonthCalendar


RightToLeftLayoutGrip
Control


ToolStripProgressBarControl
ProgressBar


PropertyGridView
Control


SnappableControl
Control


CommandsPane
PropertyGrid.SnappableControl


HelpPane
PropertyGrid.SnappableControl


TabOrder
Control


TextBoxBase
Control


MultilineStringEditorUI
RichTextBox


ridViewTextBox
TextBox


mplateTextBox
TextBox


ToolStripTextBoxControl
TextBox


UpDownEdit
TextBox


ToolStripAdornerWindow
Control


TrayControl
Control


PageSelector
TreeView


Selector
TreeView


UpDownButtons
Control


WebBrowserBase
Control





Steps to reproduce

Include a MemoryLeaks_Form to WinformsControlsTest (impemented in https://github.com/dkazennov/winforms/tree/MemoryLeaks_Form).
Test each form with WinDbg and Inspect.

The separate application to test memory leaks (it uses checkbox instead of buttons to switch between the forms to isolate the Button tested class memory objects):
MemoryLeaksApp.zip

Closing comment (2022-07-07T15:38:57Z): I found that ListView does have a leak, if testing with Narrator or not refreshing tree in Inspect. Will be tracked in #7385.