I am currently writing a node.js / socket.io application, but the question is common to javascript.
I have an associative array that preserves the color for each client connection. Consider the following:
var clientColors = new Array(); //This execute each new connection socket.on('connection', function(client){ clientColors[client.sessionId] = "red"; //This execute each time a client disconnect client.on('disconnect', function () { delete clientColors[client.sessionId]; }); });
If I use the delete operator, I fear that this will lead to a memory leak, since the property named client.sessionId (associative arrays - objects) will not be deleted, its reference to its value will be gonne, but the property will still exist in the object .
I'm right?
source share