How to properly cleanup and avoid namespace memory leaks in Socket.IO #5321
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Could it be that namespaces aren't designed to be manually cleaned up? |
Beta Was this translation helpful? Give feedback.
-
Hi! You can use the const io = socketio(3000, {
pingTimeout: 60000,
allowEIO3: true,
cleanupEmptyChildNamespaces: true,
}); This way, when all sockets leave the dynamic namespace, then it gets closed and cleaned up properly. Reference: https://socket.io/docs/v4/server-options/#cleanupemptychildnamespaces |
Beta Was this translation helpful? Give feedback.
-
Hello, Is there anything else that I need to do to make sure that the memory is freed ? |
Beta Was this translation helpful? Give feedback.
Hi! You can use the
cleanupEmptyChildNamespaces
option:This way, when all sockets leave the dynamic namespace, then it gets closed and cleaned up properly.
Reference: https://socket.io/docs/v4/server-options/#cleanupemptychildnamespaces