ws: Memory leak?
my code:
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({ port: 8081 });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});
When 20000 clients connected, memory usage is 2.864 GB. Then close all clients, After a few minute, memory usage is 2.188GB. And, after 20000 new clients connected, memory usage is 4.137 GB. It looks like that memory did not free.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 21 (8 by maintainers)
I have managed to reduce leakage by setting ‘perMessageDeflate: false’. I’ve dumped rss mem and found a weird endless recursive call in perMessageDeflate->zlib->_onTimeout->_onTimeout->… method (I don’t remember now if these are exact method names, but at least you have a guidance). Didn’t had time to dig deeper into zlib implementation.