NodeJS : How to debug "EventEmitter memory leak detected. 11 listeners added"

It turns out that this is a bug in nodejs core, we are talking about this problem here : https://github.com/joyent/node/issues/5108

Solution for bugged http servers thats throw an EventEmitter memory leak detected and fill up the available memory / available CPU times :

Revert to legacy version v0.8.23. (You can download and install/compile it from here : http://blog.nodejs.org/2013/04/08/node-v0-8-23-legacy/)

UPDATE 2018 : I see several feedbacks on this topic whereas the problem looks to be gone since years. Note that this response is only for a leaking http server build with nodejs. If you are in other scenario, please look the others responses on this thread and dont downgrade your version (as suggested on this response), you will waste your time.


For me it's looks like your event loop is blocked. This can happen if you are doing cpu intensive tasks in node.js event loop. You can use child process to do intensive task.

You can check what is blocking node.js using following methods:

  1. Measure computation time of each call. Log if time is high so you know app is misbehaving.
  2. Set up a log schedule so you know when something blocking loop
    function timeTick() {
        var startTime = (new Date().getTime());
        function onTick() {
            var interval = (new Date().getTime()) - startTime;
            if(interval > 5)
                console.log('timeTick(): WARNING: interval = ' + interval);
        }
       process.nextTick(onTick);
    }
    setInterval(timeTick, 1000);
  3. Use profile.
  4. Use this for logging and profiling. It's library used in Nodejitsu.