September 2009 Entries

In WPF there are some situations when memory leaks. Of course part of this has to be assigned to handlers that were not removed on finalizing. This situation is well known from Winforms and it shouldn't be anything new for .net developers. However Windows Presentation Foundation have separate GUI layer witch push into using binding data. Binding is another situation that can make leaks. To avoid it programmer should use BindingOperations.ClearBinding method. It doesn't matter is binding implemented on GUI layer or in procedural code. Same situation is with handlers of course. Adequate to binding is case of use Command Binding. Mainly CommandBinding is a little bit complicated binding so it is also have to be released. There were some problems with leaking of BitmapImage but after SP1 for .Net 3.5 there is nothing to worry about. After all there is one more thing that I've found and this is registering handler on class layer. EventManager have method to register class handler but there is no method to unregister it. To workaround it programmer have to create a static method that handle an event.