Hey all,
Curiosity runs wild.

Suppose I have this code...
VB.net Code:
  1. Do
  2.             Static count As Integer = 0
  3.             Me.PictureBox1.Image = New Bitmap(5000, 5000)
  4.             count += 1
  5.             Debug.Print(count)
  6.             'breathe
  7.             Threading.Thread.Sleep(10000)
  8.         Loop
When I run this and watch memory consumption in the task manager, memory for the app continuously increases until I finally get an ArgumentException from System.Drawing.dll after 14 iterations.

If however I add a GC.Collect to the code, memory stays in check and it will continue to run...
vb.net Code:
  1. Do
  2.             Static count As Integer = 0
  3.             Me.PictureBox1.Image = New Bitmap(5000, 5000)
  4.             GC.Collect()' <---- Adding this allows the loop to run indefinitely
  5.             count += 1
  6.             Debug.Print(count)
  7.             'breathe
  8.             Threading.Thread.Sleep(10000)
  9.         Loop
It was my understanding the the CLR will collect the garbage as needed, so what gives? Why do I need to manually collect garbage for this to work?