Skip to content

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

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions