Skip to content

DataGridView: Excessive CPU+memory usage when closing form #14204

@dpmm99

Description

@dpmm99

The root cause seems to be that this enumeration clones every row and cell in the DataGridView.

The result is it takes ~12 minutes and ~8 GB extra memory just to dispose a DataGridView with ~700k rows.

Abbreviated stack trace:
DataGridViewRowCollection.this[int].get(int index) Line 137
DataGridView.ReleaseUiaProvider(HWND handle) Line 25605
Control.WmDestroy(ref Message m) Line 11463

Workaround: setting every DataGridView's DataSource = null in the FormClosing event eliminates the issue. That seems to imply there's another problem with consistency--if ReleaseUiaProvider needs to be called for every single cell during WmDestroy, why wouldn't it be needed when clearing the DataSource?

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions