title: Using floating curly braces to free variables early in C#
body: <p>C# variables are instantiated where the type is declared (eg <code>string s;</code>) and freed at the closing brace of the current scope:</p>
  
  <pre><code>// Operates with Q memory
  void FantasyMethod() {
      var o = new BigObject();
  
      {
          var temp = new BigObject();
          Populate(temp); // Populates o1 with N megabytes of data
  
          o = PerformSomeOperationsOn(temp); // Returns a BigObject of size M (M is close to N)
  
          // Currently, M+N memory is occupied, we have Q-M-N free
      }
  
      // Let's tell the garbage collector to catch up
      GC.Collect();
      GC.WaitForPendingFinalizers();
  
      // Currently, M memory is occupied
  
      DoUsefulStuffWith(o); // This method can only work if at least Q-M-N/2 memory is free
  }
  </code></pre>
  
  <p>One benefit of this is that I can free large variables before the function returns. In the above (trivial) block, I have husbanded my limited available memory by disposing a large variable as soon as it is no longer needed.</p>
  
  <ol>
  <li>Is the above correct?</li>
  <li>Is doing this a good idea (I am interested in arguments for and against, not personal opinion or preference)? Would extracting the naked brace block as a method use memory less efficiently? What if I don't want to make a new method for readability reasons?</li>
  </ol>