I have a form that can be dynamically added to a devexpress tab control. When you click the tab for the first time the control is there. You can add additional ones as you see fit. Each one has a delete button on it. However, if you click the add button it adds about 30 MBs under the running process. When you delete one on there the MBs stay in memory.
My delete code:
MyCustom temp = this._UIList[idx] as MyCustom;
if (this._UIList.Count == 1)
{
temp.Clear();
}
else
{
if (temp != null)
{
this._UIList.RemoveAt(idx);
this._UIList.TrimToSize();
this.pnlInner.Controls.Remove(temp);
temp.CleanUP();
temp.Dispose();
//now reshuffle all the note controls
ReshuffleMyCustomControls();
}
}
Any direction would be very helpful. Thanks.
Make sure you remove any event handlers that got wired up. They can hold the reference in memory.
You’d have to do something like this for any event you wired up: