title: Would EventEmitter cause memory leak if removeAllListeners() is not called?
body: <p>This question came into my head when I was working with node-imap module.  (See <a href="https://github.com/mscdex/node-imap" rel="nofollow">https://github.com/mscdex/node-imap</a>)</p>
  
  <p>In this module, the fetch() method would call a callback function that gives it an ImapFetch() object, which your code is suppose to listen on for a 'message' event.  The message event in turns passes a message object for each object with events that you need to listen on.</p>
  
  <p>Here's the sample code from the module:</p>
  
  <pre><code>imap.fetch(results,
    { headers: ['from', 'to', 'subject', 'date'],
      cb: function(fetch) {
        fetch.on('message', function(msg) {
          console.log('Saw message no. ' + msg.seqno);
          msg.on('headers', function(hdrs) {
            console.log('Headers for no. ' + msg.seqno + ': ' + show(hdrs));
          });
          msg.on('end', function() {
            console.log('Finished message no. ' + msg.seqno);
          });
        });
      }
    }, function(err) {
      if (err) throw err;
      console.log('Done fetching all messages!');
      imap.logout();
    }
  );
  </code></pre>
  
  <p>As shown, the listeners are never removed.  This might be fine if the process quits right after it runs once.  However, if the process is long running, the code get repeatedly executed, would it cause a memory leak? I.e. since the listeners are never removed, they keep all the fetch and message objects around even though they are only used for the duration of the command.</p>
  
  <p>Is my understanding incorrect?</p>