title: garbage collection with node.js
body: <p>I was curious about how the node.js pattern of nested functions works with the garbage collector of v8.
  here's a simple example</p>
  
  <pre><code>readfile("blah", function(str) {
     var val = getvaluefromstr(str);
     function restofprogram(val2) { ... } (val)
  })
  </code></pre>
  
  <p>if restofprogram is long-running, doesn't that mean that str will never get garbage collected? My understanding is that with node you end up with nested functions a lot. Does this get garbage collected if restofprogram was declared outside, so str could not be in scope? Is this a recommended practice?</p>
  
  <p><strong>EDIT</strong> I didn't intend to make the problem complicated. That was just carelessness, so I've modified it.</p>