title: Where did variable = null as "object destroying" come from?
body: <p>Working on a number of legacy systems written in various versions of .NET, across many different companies, I keep finding examples of the following pattern:</p>
  
  <pre><code>public void FooBar()
  {
      object foo = null;
      object bar = null;
  
      try
      {
         foo = new object();
         bar = new object();
  
         // Code which throws exception.
      }
      finally
      {
         // Destroying objects
         foo = null;
         bar = null;
      }
  
  }
  </code></pre>
  
  <p>To anybody that knows how memory management works in .NET, this kind of code is painfully unnecessary; the garbage collector does not need you to manually assign <code>null</code> to tell that the old object can be collected, nor does assigning <code>null</code> instructs the GC to immediately collected the object. </p>
  
  <p>This pattern is just noise, making it harder to understand what the code is trying to achieve.</p>
  
  <p>Why, then, do I keep finding this pattern? Is there a school that teaches this practice? Is there a language in which assigning <code>null</code> values to locally scoped variables is required to correctly manage memory? Is there some additional value in explicitly assigning <code>null</code> that I haven't percieved?</p>