title: WPF Listbox memory leak
body: <p>Here's my xaml:</p>
  
  <pre><code>&lt;ListBox Grid.Row="4" HorizontalAlignment="Stretch" Margin="10,132,10,10"  ScrollViewer.VerticalScrollBarVisibility="Disabled" Name="lbStatus" VerticalAlignment="Stretch" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling"/&gt;
  </code></pre>
  
  <p>and my C# code:</p>
  
  <pre><code>  public void DisplayStatusMessage(string msg)  
    {
         if (lbStatus.Dispatcher.CheckAccess())
         {
            AddMessage(msg, Brushes.Black);
         }
         else
         {
            this.Dispatcher.BeginInvoke((Action)(() =&gt;
            {
              AddMessage(msg, Brushes.Black);
             }));
         }   
    }
  
  
  
    private void AddMessage(string msg)
    {
       ListBoxItem status = new ListBoxItem();
       status.Content = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss:fff ") + msg;
  
       lbStatus.Items.Add(status);
       lbStatus.ScrollIntoView(status);
       status = null;
     }
  </code></pre>
  
  <p>I am calling DisplayStatusMessage within while (true) loop to display status on the listbox.  My application grows considerably in size overnight, which seems to indicate a memory leak on the listbox. Is there an alternative to the listbox to display infinite status ? I thought setting the Virtualization to recycling would prevent from leaking ?</p>