dotnet/winforms

DataGridView not dispose old elements

Open

#6 859 ouverte le 17 mars 2022

Voir sur GitHub
 (11 commentaires) (0 réactions) (0 assignés)C# (922 forks)batch import
area-controls-DataGridViewhelp wantedtenet-performance

Métriques du dépôt

Stars
 (4 100 stars)
Métriques de merge PR
 (Merge moyen 14j 22h) (56 PRs mergées en 30 j)

Description

  • .NET Core Version: all up to 7.0 p2

  • Have you experienced this same bug with .NET Framework?: Yes

Problem description: As I mentioned in https://github.com/dotnet/winforms/issues/6858 DataGridView not dispose old data on DataSource change. This is lead to 2 problems:

  1. All this stuff are going to finalization query because we have unnecessary finalizer here #6858.
  2. If we have a ContextMenuStrip bound to Cell/Column/Row we will have a memory leak. DataGridView with 3 columns and ContextMenuStrip bound to 1000 rows, result of DS refresh: image

Expected behavior: Old data must be property disposed. Probably in DataGridView.RefreshColumnsAndRows() (in DataGridView.Methods.cs)

Minimal repro: DataGridViewLeak.zip

Guide contributeur