WPF memory leak with custom control
问题 I want to dispose of a control I'm dynamically adding to my app. The garbage collector is not picking up the object after I .Remove() it from its parent control, and it has huge bitmaps and geometry private members. I want to be able to do something like this: foreach (ScrollItem mylabel in canvas1.Children) { if (mylabel.bRemove == true) { canvas1.Children.Remove(mylabel); mylabel = null; // or mylabel.Dispose(); } } canvas1 can't have null items in a UIObjectCollection so I can't set it to