title: Do closures keep the whole execution context alive?
body: <p>I understand that closures keep the execution context alive by saving a reference to the executed function.</p>
  
  <p>I'm wondering whether the whole context is saved or only the required parts.<BR>In the former case I need to structure the functions in a way that no memory is wasted. This should be the design goal anyway, but I would like to know if JavaScript takes care of it, too.</p>
  
  <p>Here's a simple example (on the basis of <em>Single Page Web Applications</em>, Mikowski/Powell, p. 56):</p>
  
  <pre><code>var ctx;
  var outer_function = function () {
      var dummy = 'not required for output';
      var output = 'output';
      var inner_function = function () {
          return { output: output };
      }
      return inner_function;
  };
  
  ctx = outer_function();
  // returns { output: 'output' }
  ctx();
  </code></pre>
  
  <p>Is the <code>dummy</code> object stored in the closure after the execution of 
  <code>outer_function</code> even though it is not accessible and won't be used?</p>