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

Memory leak prevention / warnings

Open peteruithoven opened this issue 9 years ago • 4 comments

When I used socket.io-stream for a bigger project where I did things like pipe multiple streams and sometimes streams where not handled on the end I ran into lots of little memory leak issues. I really had to dive into how socket.io-stream works to figure out what was going wrong. So I'd like to come up with ways to make this easier for other people. One of the "invisible" problem areas is that each socket.io-stream socket stores references to socket.io-stream streams it uses. When streams are not handled these streams keep piling up. This is especially problematic when you put streams in flowing mode and they already have a chunk of data in their buffer.

  1. One first thing I would do is log (using debug) the amount of stored streams, this way people see this growing number. Preferably when the streams are added.
  2. Another idea might be to give a warning when a certain amount is reached, like Node.js's max listeners warning.
  3. Could it be that streams don't get removed when an error occurs? I wrote error handlers on streams that would manually end() and destroy() that stream.

peteruithoven avatar May 28 '15 11:05 peteruithoven