LearnBoost/socket.io — Issue #608: Memory leak in namespaces
Author: samlown
Created: 2011-10-31 19:21:08+00:00
State: open

Hi,

While trying to produce a list of sockets currently connected to the server I discovered a minor memory leak. When using several namespaces, for some reason each connection to the server creates a new socket instance in each namespace's object, despite only one being required.

When the client disconnects, only the specified namespace's socket object is removed, all the other namespaces are left with an empty socket instance with disconnected == false.

This can be seen by listing a namespaces sockets, connecting to a different namespace, closing, then refreshing the first namespaces sockets list. Quick pseudo example:

io.of('/drivers').sockets.length == io.of('/riders').sockets.length == 0
# Client connects to '/drivers'
io.of('/drivers').sockets.length == io.of('/riders').sockets.length == 1
# Client disconnects from '/drivers'
io.of('/drivers').sockets.length == 0
io.of('/riders').sockets.length == 1

Cheers,
sam