title: .NET - Adding referenced variable to arraylist vs adding new Object() to ArrayList
body: <p>I was just wondering if there are any performance differences (specifically memory usage) when I do the following...</p>
  
  <p>Instead of doing:</p>
  
  <pre><code>ArrayList array = new ArrayList();
  object obj = new object();
  
  for(int x = 0; x &lt; 100; x++)
  {
      array.Add(obj);
  }
  </code></pre>
  
  <p>I do this:</p>
  
  <pre><code>ArrayList array = new ArrayList();
  
  for(int x = 0; x &lt; 100; x++)
  {
      array.Add(new object());
  }
  </code></pre>
  
  <p>Or is it exactly the same thing?</p>
  
  <p>As I understand it, the system holds a reference to the obj variable in memory, once the method finishes, the variable gets disposed and the memory is freed</p>
  
  <p>So, if I call <code>ArrayList.Add(new Object())</code> on each loop, then there is no memory being allocated to a referenced variable?</p>