Skip to content

How to properly cleanup and avoid namespace memory leaks in Socket.IO #5321

Answered by darrachequesne
emanuelef asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! You can use the cleanupEmptyChildNamespaces option:

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

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@emanuelef
Comment options

@emanuelef
Comment options

Answer selected by emanuelef
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants