socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

"Emit" leaks memory when using acknowledgement callback.

Open ErbolLab opened this issue 7 years ago • 2 comments

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

When emitting message with acknowledgement callback, it starts leaking the memory.

Steps to reproduce (if the current behaviour is a bug)

// this will leak the memory ( with acknowledgements callback)
client.socket.emit('some_event', payload, (data) => {});

// this works fine
client.socket.emit('some_event', payload);

Expected behaviour

it shouldn't leak the memory

Setup

  • OS: macOS High Sierra
  • browser: Google Chrome 77.0.3865.90 (Official Build) (64-bit)
  • socket.io version: ^2.0.4

Other information (e.g. stacktraces, related issues, suggestions how to fix)

To clearly see that it's leaking the memory please perform several thousand emits.

ErbolLab avatar Oct 11 '19 21:10 ErbolLab

Could have 2 causes:

  1. The socket is in the broadcast mode, where an error will be thrown and cause memory leak, though you should be able to see error messages on your server's console.
  2. The ACK packet is never received (i.e. the client/server not handling the connections correctly), in which case the callbacks are registered but never invoked (meaning they will stick around forever, until an ACK is received), hence causing the leak.

I think case-2 is probably the actual cause of the problem you see.

Chopinsky avatar Oct 12 '19 04:10 Chopinsky

Closed due to inactivity, please reopen if needed.

darrachequesne avatar Jun 17 '21 12:06 darrachequesne