Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Websocket Memory Leak #880

crickeys opened this Issue · 2 comments

2 participants

crickeys Einar Otto Stangvik

Using Node 0.6.* branch:

If I enable websockets in the transport list there is a slow memory leak that eventually causes an OOM (out of memory) killer to take down Node. As well my connected clients count seems to rise continuously. It should be noted that I'm not even that sure how to get an accurate connected client count. Currently, I simply increase a global variable (gTotalConnected) during an on('connection') event and decrease it during the on('disconnect') event.

If I disable websockets and currently just have XHR-POLLING and HTMLFILE. All is right as rain. Memory stays nice and low and connection count (though seemingly a little high) goes up and down with time. So, something is definitely leaking or not closing in websockets which makes it unusable for my production settings. About every 3 hours I'd run out of memory.

Also noteworthy, running things with JUST XHR-POLLING really seems fine in terms of my server resources and connect time. Is it worth just doing that and avoiding websockets entirely?

I can't seem to reproduce this memory leak with a test case, only in production :(

Has anyone else experienced something like this?

Einar Otto Stangvik

It would be interesting to know if this is a or ws issue. From what I gather, the memory situation with ws has improved somewhat with the work put in by @nicokaiser, along with fixes committed to node core.


@nicokaiser mentioned (websockets/ws#43 (comment)) that he was using a version of websocket(?) that calls socket.destroy to every socket.end() call. He referenced this ws issue (websockets/ws#64).

Looking over the websocket libraries in it doesn't appear to have a socket.destroy after the socket.end() calls. Could this be causing the problems here?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.