title: What is the correct way to free memory in C#
body: <p>I have a timer in C# which executes some code inside it's method. Inside the code I'm using several temporary objects.</p>
  
  <ol>
  <li><p>If I have something like <code>Foo o = new Foo();</code> inside the method, does that mean that each time the timer ticks, I'm creating a new object and a new reference to that object?</p></li>
  <li><p>If I have <code>string foo = null</code> and then I just put something temporal in foo, is it the same as above?</p></li>
  <li><p>Does the garbage collector ever delete the object and the reference or objects are continually created and stay in memory?</p></li>
  <li><p>If I just declare <code>Foo o;</code> and not point it to any instance, isn't that disposed when the method ends?</p></li>
  <li><p>If I want to ensure that everything is deleted, what is the best way of doing it:</p>
  
  <ul>
  <li>with the using statement inside the method</li>
  <li>by calling dispose method at the end</li>
  <li>by putting <code>Foo o;</code> outside the timer's method and just make the assignment <code>o = new Foo()</code> inside, so then the pointer to the object is deleted after the method ends, the garbage collector will delete the object.</li>
  </ul></li>
  </ol>