Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 socket.io 中,当客户端与服务器断开连接时,disconnect会在服务器中为套接字触发事件。我必须removeAllEventListeners()从插座$events吗?或者当套接字死亡时它会自动发生吗?我听说如果我不这样做,内存泄漏可能会出现在服务器上......
disconnect
removeAllEventListeners()
$events
After digging through the socket.io source, the socket object (which is the EventEmitter) is deleted when the client disconnects so it is not necessary to manually call removeAllListeners.