The Potential Binding Leaks In WPF view tracks whether there are potentially leaking property bindings.
This includes bindings to properties that:
are in classes, not implementing the INotifyPropertyChanged;
don`t have their binding mode set to OneTime;
are not Dependency Properties.
To see the potential WPF binding leaks in the Type List, enable them by pressing the
Binding Leaks button
() in the ribbon. Then, you will be able to distinguish them by the icon in the type list:
How to fix such leaks in your code
There are three possible ways:
Implementing the INotifyPropertyChanged interface.
To assure you won`t suffer the consequences of having a binding leak in your code is to implement INotifyPropertyChanged
in all classes which are targets of databinding.
Setting the databinding mode to OneTime.
This will prevent the memory leak. However, you will need to determine which
of the data bindings are appropriate for this mode. Binding Mode=OneTime
tells the property that, its value can be set only once from the code-behind.
After that it shouldn`t change ever again. That`s why,
use this mode only for properties,
you are certain that won`t change.
Chnaging your regular property to DependencyProperty.
Dependency properties are heavy weight and staticaly declared. However, they have richer functionality and oftern are very useful.
For example, you get notified on property value change simply by registering a callback in the property metadata.
Getting started with the Potential Binding Leaks In WPF view
The Just My Types toggle button filters out all types which are not user code.
You can control which assemblies are considered user code in the Assembly List view.
By double clicking on a type or by clicking the Instances icon in the ribbon,
you can open a new tab with the Instances List view to examine all objects of the selected class.
Each row of the table holds the following information:
- Class Name - fully qualified name of the type.
- Instances - number of alive instances of this type at the moment the snapshot was taken.
- Total Retained Size - the sum of the retained sizes of all instances.