title: An unhandled exception of type 'System.OutOfMemoryException' occurred in System.Drawing.dll Additional information: Out of memory
body: <p>I have a list "images" that contains about 20 photos about 1MB each. I want to scroll through the images in the list by clicking the next button. But after about 8 pictures I get out of memory.</p>
  
  <pre><code>    private void button4_Click(object sender, EventArgs e) //next
      {
          index++;
          if (index &gt;= images.Count) index = 0;
          CurrImage = images[index]; 
          Bitmap b = new Bitmap((Bitmap)CurrImage.Clone()); //breakpoint occurs her
          pictureBox1.Image = b; 
  
          NewThread = new Thread(new ThreadStart(ChooseColors2));
      }
  </code></pre>
  
  <p>ChooseColors2 thread will use "CurrImage" so to avoid race conditions, I avoided that by creating a new bitmap as shown above </p>
  
  <p>Please note that if I use pictureBox1.Image = CurrImage; without creating a new bit map I don't get this error but there will be race condition exception with the thread.</p>