I'm experiencing a memory leak in my WPF application.
I want to GC my DiffViewControl, but it's retained by the Window.EffectiveValues
instance.
Do you know how could I clean this obsolete reference and then the DiffViewControl can be GC'd?
Finally I figured out the problem after reading this post:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/1283a5da-48c2-4398-9064-a92f569d657d/wpf-textboxfocus-results-in-usercontrol-garbage-collection-problem?forum=wpf
My problem is that if I close the WPF window, and a textbox in that window has the focus, the textbox is leaked, so the entire window is leaked.
The solution in my case is removing the focus from any textbox in the window before closing it.
Keyboard.ClearFocus();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With