title: Out of memory when using BitmapSource
body: <p>I'm changing source of a WPF image on run time with a frequency of 30ms ( 30 fps ). I'm getting an OutOfMemory.
  In the following code, iImage is a private object displayed and owned by the wpf application.
  bytes is a byte array readed and stored once at the creation of the window.</p>
  
  <p>How can I avoid the outOfMemory ?
  Is there a better solution to have a better performance to display a raw byte array ?</p>
  
  <pre><code>public void LoadBitmapImage(Byte[] bytes, Image iImage)
  {  
  
    int bitsPerPixel = 24;
    double stride = (1024 * bitsPerPixel + 7) / 8;
    BitmapSource wBitmapSource = BitmapSource.Create(1024, 768, 96, 96, PixelFormats.Rgb24, null, bytes , (int)stride);      
  
    iImage.Source = wBitmapSource;
  
  }
  </code></pre>
  
  <p>Thks</p>