title: Out of Memory Exception when Processing Large Number of Images
body: <p>Im using the following code to fix the Orientation of Images depending on EXIF Data</p>
  
  <pre><code> Image FixImageOrientation(Image srce)
          {
              const int ExifOrientationId = 0x112;
              // Read orientation tag
              if (!srce.PropertyIdList.Contains(ExifOrientationId)) return srce;
              var prop = srce.GetPropertyItem(ExifOrientationId);
              var orient = BitConverter.ToInt16(prop.Value, 0);
              // Force value to 1
              prop.Value = BitConverter.GetBytes((short)1);
              srce.SetPropertyItem(prop);
            //  MessageBox.Show(orient.ToString());
              // Rotate/flip image according to &lt;orient&gt;
              switch (orient)
              {
  
                  case 1:
                      srce.RotateFlip(RotateFlipType.RotateNoneFlipNone);
                      return srce;
  
  
                  case 2:
                      srce.RotateFlip(RotateFlipType.RotateNoneFlipX);
                      return srce;
  
                  case 3:
                      srce.RotateFlip(RotateFlipType.Rotate180FlipNone);
                      return srce;
  
                  case 4:
                      srce.RotateFlip(RotateFlipType.Rotate180FlipX);
                      return srce;
  
                  case 5:
                      srce.RotateFlip(RotateFlipType.Rotate90FlipX);
                      return srce;
  
                  case 6:
                      srce.RotateFlip(RotateFlipType.Rotate90FlipNone);
                      return srce;
  
                  case 7:
                      srce.RotateFlip(RotateFlipType.Rotate270FlipX);
                      return srce;
  
                  case 8:
                      srce.RotateFlip(RotateFlipType.Rotate270FlipNone);
                      return srce;
  
                  default:
                      srce.RotateFlip(RotateFlipType.RotateNoneFlipNone);
                      return srce;
              }
          }
  </code></pre>
  
  <p>I process a large batch of Images like this</p>
  
  <pre><code>for (x= 0; x&lt;list.Count; x++)
  {
  filepath= list.ElementAt(x);
  Bitmap image = new Bitmap(FixImageOrientation(Bitmap.FromFile(filepath)));
  //Do long processing and at the end i do image.dispose();
  image.dispose();
  }
  </code></pre>
  
  <p>But when processing a large batch of images i get Out of Memory exception at </p>
  
  <pre><code>Bitmap image = new Bitmap(FixImageOrientation(Bitmap.FromFile(filepath)));
  </code></pre>
  
  <p>Why do i get this..  I dispose this image at the end of the loop i guess.</p>