title: Memory Leaks in Javascript
body: <p>I'm using the <code>featherlight</code> <a href="http://noelboss.github.io/featherlight/" rel="nofollow">library</a> to show lightboxes. I'm using coffee and so at the beginning of my js file I have</p>
  
  <pre><code>myFeatherBox = void 0;
  </code></pre>
  
  <p>Later, when I want to use it I do stuff like this:</p>
  
  <pre><code>if (myFeatherBox != null) {
    myFeatherBox.close();
  }
  myFeatherBox = $.featherlight("&lt;div&gt;whatever&lt;/div&gt;");
  </code></pre>
  
  <p>I test for null in case a featherbox is already opened, in which case I close it. To avoid leaving masses of these things in memory though, I'm essentially creating a new box in the old variable.</p>
  
  <p>So I'm wondering whether that's just orphaning the old box in memory (and if so how to clean it) and whether this is the way to do things.</p>