Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not pretend to answer, just for reference. In a classic article on <a href="http://blogs.msdn.com/b/jgoldb/archive/2008/02/04/finding-memory-leaks-in-wpf-based-applications.aspx"><code>Finding Memory Leaks in WPF-based applications</code></a> author <em>Jossef Goldberg</em>, described in detail cases, where there may be a memory leak in WPF application. Really, most relate to the .NET 3.5/4.0, but some cases may be relevant to this day. Also, have a small <a href="http://blogs.msdn.com/b/jgoldb/archive/2010/06/14/memory-leak-hotfixes-for-wpf-3-5-sp1.aspx">extension</a>.</p> <p>Quote about leak in <code>Binding</code>:</p> <p><code>Cause:</code></p> <p>This leak documented in this <a href="http://support.microsoft.com/kb/938416/en-us">kb article</a>. It is triggered because:</p> <p>The <code>TextBlock</code> control has a binding to an object (myGrid) that has a reference back to the <code>TextBlock</code> (it is one of myGrid children’s).</p> <p><code>Note:</code> that this type of a DataBinding leak is unique to a specific scenario (and not to all DataBinding scenarios) as documented in the <a href="http://support.microsoft.com/kb/938416/en-us">kb article</a>. The property in the <code>Path</code> is a not a <code>DependencyProperty</code> and not on a class which implements <code>INotifyPropertyChanged</code> and in addition a chain of strong reverences must exist.</p> <p>Code:</p> <pre><code>myDataBinding = new Binding("Children.Count"); myDataBinding.Source = myGrid; myDataBinding.Mode = BindingMode.OneWay; MyTextBlock.SetBinding(TextBlock.TextProperty, myDataBinding); </code></pre> <p>Same leaky code can be also written in XAML:</p> <pre><code>&lt;TextBlock Name="MyTextBlock" Text="{Binding ElementName=myGrid, Path=Children.Count}" /&gt; </code></pre> <p><code>Fix/Workaround:</code></p> <p>There are few of approaches, the easiest one is simply to clear the binding when the windows is about to close. </p> <p>e.g.:</p> <pre><code>BindingOperations.ClearBinding(MyTextBlock, TextBlock.TextProperty); </code></pre> <p>Other approach is to set the mode of the data binding to OneTime. See the <a href="http://support.microsoft.com/kb/938416/en-us">kb article</a> for other ideas.</p> <p>Useful link:</p> <p><a href="http://blogs.msdn.com/b/micmcd/archive/2008/03/07/avoiding-a-wpf-memory-leak-with-databinding-black-magic.aspx">Avoiding a WPF memory leak with DataBinding</a> </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload