
A recent predicament found me getting a memory leak on a Tabbed Control every time the visibility changed. The cause had to do with PropertyMap – the component that links winforms and WPF. It transpired that garbage colleciton was not working with a single item – BackgroundImage. Fix below:
1 2 3 4 5 6 7 8 9 10 11 |
Private Sub BrushesEH_VisibleChanged(sender As Object, e As EventArgs) Handles BrushesEH.VisibleChanged If BrushesEH.Visible = False Then BrushesEH.PropertyMap.Remove("BackgroundImage") GC.Collect() Else BrushesEH.PropertyMap.Reset("BackgroundImage") GC.Collect() End If End Sub |
Leave a Reply