title: On jquery, closures, and possible memory leaks
body: <p>I've read quite a bit about how memory leaks are created in various versions of IE.
  Some great information can be found here:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/bb250448%28VS.85%29.aspx</a></p>
  
  <p><a href="http://laurens.vd.oever.nl/weblog/items2005/closures/" rel="nofollow noreferrer">http://laurens.vd.oever.nl/weblog/items2005/closures/</a></p>
  
  <p>Using closures with JQuery is a very common practice.  I can't find any articles at all that speak to JQuery's event model (where closures are heavily used) with regards to IE and memory leaks  In the second article posted above is a strategy to avoid memory leaks when using closures.</p>
  
  <p>Does JQuery already implement a strategy similar to the one outlined in the article with regards to helping clean up potential leaks when using closures? Or is that something I must be aware of and code for?</p>
  
  <p>For example, </p>
  
  <p>Creates a memory leak in IE6/7:</p>
  
  <pre>
  function foo(value) {   
      var bar = document.getElementById("selector");
      bar.attachEvent("onclick", 
          // closure
          function() {
              alert(value); // reference to 'value' from outer function scope   
          }
      ); 
  }
  </pre>
  
  <p>does the following JQuery version of the above example cause a memory leak in IE6/7?</p>
  
  <pre>
  function foo(value) {   
      $('#selector').click(
          // closure
          function() {
              alert(value); // reference to 'value' from outer function scope   
          }
      ); 
  }
  </pre>