Open crickeys opened 12 years ago
What's a cyclic assertion? You mean, you're getting an error message about the socket not disappearing from RAM?
You might want to call the gc()
function explicitely, like here: https://github.com/LearnBoost/socket.io/blob/master/test/leaks/socket.leaktest.js
I reran the code with gc() still got the assertion that socket did not disappear from RAM (Cyclic).
However, I think it's actually accurate. Because I was passing socket
here:
socket.on('disconnect', event_disconnect(socket) );
I thought I had to but I didn't realize that all the socket.on functions all have a reference to the socket via this
. So, I guess I was passing socket via a closure and never released the closure (cause I don't really understand how here) and that caused the leak.
If I changed it to this:
socket.on('disconnect', event_disconnect );
it seems to help. If that makes any sense at all.
Not sure... that should only matter if you have permanent references to those functions, I think...
The following code creates a cyclic assertion. Should it??
io.sockets.on('connection', function (socket) { // setup listeners for this socket
setup_socket_events(socket);
});
function setup_socket_events(socket) { socket.on('disconnect', event_disconnect(socket) ); } function event_disconnect(socket) {
}