Skip to main content
A newer version of this page is available. .
All docs
V22.1

DXWIN0005: A Form Dialog is Never Disposed

Severity: Warning

Any Form displayed as a dialog (with the ShowDialog() method) must be disposed when not needed anymore. Otherwise, it may cause memory leaks.

Invalid Code

Form dialog1 = new Form();
dialog1.ShowDialog();

Valid Code

using (Form dialog1 = new Form()) {
    dialog1.ShowDialog();
}

// or

Form dialog1 = new Form();
dialog1.ShowDialog();
dialog1.Dispose();