title: Reading Node.js Heap Snapshots (created via Nodetime) -- why are my objects not GC'd?
body: <p>I'm having some surprising results in my Nodetime heap snapshot:</p>
  
  <p><img src="https://i.stack.imgur.com/Gsdt3.png" alt="enter image description here"></p>
  
  <p>Am I reading this right that there are 1706 instances of a "user" in my heap? This seems absurdly high, I'm not even quite sure how I would have allocated that many. In any case, are there any tips / tricks / hints to find out why these are hanging around? I've already used JSHint on my code to ensure there are no free globals being allocated. Everything should be wrapped in the closure scope of the request... so why aren't the users, posts, etc. being garbage collected when the request finishes? Here's some (redacted) code to show how I'm doing things...</p>
  
  <p>What's very surprising is that <strong>I took the above heap snapshot about 10m after the last API call finished</strong>. So, those objects were all hanging around for long after the requests which triggered them to be allocated was finished!</p>
  
  <p>code:</p>
  
  <pre><code>var User = require('./user').User,
      Q = require('q');
  
  // this function is called via express' router, eg when the client visits myapi.com/users/zane
  function getUser(req, res, next)
  {
     var user = extend({},User).initialize();
  
     Q.ncall(user.model.find, user.model, {'username': req.arguments[0]})
     .then(function(data){
         res.writeHead(200, {});
         res.end(JSON.stringify(data));
     })
     .fail(next).end();
  }
  </code></pre>
  
  <p>And the "User" module looks something like this:</p>
  
  <pre><code>exports.User = extend({}, {
      initialize: function() {
          var Schema = api.mongoose.Schema;
          this.schema = new Schema({
              'username': {'type':String, 'index':true}
          });
          this.model = api.db.model('users', this.schema);
      }
  
      // ... some other helper functions in here
  });
  </code></pre>
  
  <p>Based upon my express code, above, I'd expect the lifespan of the user object which is allocated to be only as long as the request takes to return. Am I missing some key Node.js GC idea here?</p>