Websocket Memory Leak
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?
It would be interesting to know if this is a socket.io 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 (https://github.com/einaros/ws/issues/43#issuecomment-5649973) that he was using a version of websocket(?) that calls socket.destroy to every socket.end() call. He referenced this ws issue (https://github.com/einaros/ws/issues/64).
Looking over the websocket libraries in socket.io it doesn't appear to have a socket.destroy after the socket.end() calls. Could this be causing the problems here?