Warning: possible EventEmitter memory leak detected. 11 disconnect listeners added. Use emitter.setMaxListeners() to increase limit.
21K reputation · 12 Sept 2023, 04:58 UTC
The goal is to decide whether long‑running Socket.IO servers should manually remove namespace objects after all sockets have left a namespace to prevent gradual memory growth.
Constraints include verifying the Socket.IO version (v2.x lacks automatic room cleanup, v3.x+ calls socket.leaveAll() on disconnect), ensuring no extra listeners are added that could mask the leak, and recognizing that namespace objects remain allocated until the Node.js process ends.
Uncertainty remains about whether Socket.IO provides a safe API to destroy namespaces or if manual deletion is advisable, as the current implementation retains namespace instances indefinitely.
- Should developers explicitly delete namespace references when a namespace becomes empty?
- Does manual namespace cleanup interfere with Socket.IO’s internal state or future version behavior?