ComponentFactory / Krypton

Krypton WinForms components for .NET
BSD 3-Clause "New" or "Revised" License
1.88k stars 691 forks source link

"OutOfMemoryException" will be threw if click a button to show KryptonForm many times #223

Closed imszy closed 3 years ago

imszy commented 3 years ago

Click a button to show another KryptonForm that have many KryptonTextbox controls (about 50 controls). Click the button, then close the form many times. The memory keeps increasing and it will throw OutOfMemoryException after 10minutes.

Anyone knows how to fix it?

Smurf-IV commented 3 years ago

The recommended practice for forms is to: wrap your form creation in a using.

i.e.

            using (var startAndCheck = serviceProvider.GetRequiredService<CheckForNewerVersion>())
            {
                startAndCheck.ShowInTaskbar = true;
                if (startAndCheck.ShowDialog() != DialogResult.OK)
                {
                    Add(@"Exiting");
                    return;
                }
            }
imszy commented 3 years ago

It works. Thank you so much! @Smurf-IV

imszy commented 3 years ago

Thanks @Smurf-IV response! His solution is effective.

Smurf-IV commented 3 years ago

Great - Please close this issue then ;-)

imszy commented 3 years ago

Oh, yes. Thank you!