I've been experiencing some exceptions with the application I'm developing.
The exception is Win32Exception, Error creating window handle.
I programatically create lots of user controls & remove them, the problem seems to be that the handles creaded when the controls are added to the container are not correctly released when the controls are removed.
I've noticed that User controls that contain krypton controls don't receive the call to Dispose (or destructor) method
I've been able to reproduce the problem with this code:
I monitor the GC Handles increase with Process Esplorer (.Net/.Net CLR Memory/# GC Handles). While I'm clicking the button the handles don't stop increasing until reach the machine limit (in my case about 37000) and a exception is thrown.
Using Button instead of KryptonButton works fine, handles remain constant.
- Code: Select all
private void button1_Click(object sender, EventArgs e)
{
flowLayoutPanel1.Controls.Clear();
GC.Collect();
List<KryptonButton> testList = new List<KryptonButton>();
for (int i = 0; i < 200; i++)
{
KryptonButton b = new KryptonButton();
testList.Add(b);
}
flowLayoutPanel1.Controls.AddRange(testList.ToArray());
}