title: why does this pattern leak memory
body: <p>The following is a very simplified (and a little ugly) version of some code I have.  When I compare heap snapsnots in Chrome before the code executes and afterwards, someObject and subObjectCollection are not collected.  This confuses me because it looks like the leak is caused by circular references, which should not be an issue for the v8 garbage collector in Chrome.  What am I not seeing about this code that causes it to leak?  How can it be refactored so these objects are cleaned up?  <a href="http://jsfiddle.net/m2f9V/1/" rel="nofollow">JSFiddle</a></p>
  
  <pre><code>var someObject = function (name) {
      var _subObjects = [];
      this.name = name;
      var parent;
  
      this.getObjects = function () {
          return _subObjects;
      }
  
      this.addObject = function (o) {
          _subObjects[_subObjects.length] = o;
          o.setParent(this);
      }
  
      this.setParent = function (o) {
          parent = o;
      }
  
      this.getParent = function () {
          return parent;
      }
  }
  
  var subObjectCollection = function (name) {
      var parent;
      this.name = name;
      this.list = [];
  
  
      this.setParent = function (o) {
          parent = o;
      }
  
      this.getParent = function () {
          return parent;
      }
  }
  
  var obj1 = new someObject("Top Level Object");
  var objCollection = new subObjectCollection("Object Collection");
  obj1.addObject(objCollection);
  var obj2 = new someObject("Child Object");
  obj2.setParent(obj1);
  obj1.getObjects()[0].list[0] = obj2;
  </code></pre>