When I create a user control that has a CommandBinding for RoutedUICommand, I worry that I'm having memory leaks.
scenario:
Have RoutedUICommand as a static class c, where I store my commands Embed CommandBindings in a user control. Add a user control to the main form. Remove the user control from the main form, set links to zero for it.
The canExecute command bindings continue to run. I don't have a link to UserControl, so it leaked. and he continues to shoot for a long time after closing the form. (I did not see him stop). If I make garbage collection go (well, canExecute stops firing)
I have a project test that illustrates this. I have a Console.WriteLine in canExecute that prints the hash code of the object that starts the method. It has a button to add a new user control and one to delete it.
Should I not worry about this? user control is collected if forced. Does this mean that it will be assembled in the next collection? im noticing performance degradation in our application and tracking memory leaks etc. We have complex shapes with a lot of ui elements, and they hang around using the processor and memory space when they are removed from the layout. (we use a lot of commands), I thought that once something was removed from the visual tree, it could no longer receive routed events. What am I missing?