Closed ghost closed 3 years ago
I'm on Node.js 16.2.0 and macOS but I can't reproduce. Ran autocannon
after every snapshot and waited ~4 min before taking the snapshots.
Indeed, if we wait longer, the memory is cleared (for example, after 3.5 minutes on the screenshot below), but not always completely
after 6 minutes some closures remained in memory (possibly related only to 'restify')
The remaining question: why Garbage collector cannot clean up memory in a shorter time ("Garbage ollect" button doesn't help)
I think because there is plenty of memory available so it does not aggressively try to reclaim memory.
but it should clear the memory immediately when you click on the "Collect garbage" button, isn't?
I don't know. You can try forcing garbage collection with global.gc()
and using the --max-old-space
option. Garbage collectors are scary beasts.
I'm closing this as it does not seem to be an issue in ws. Discussion can continue if needed.
Description
Garbage collection is completely performed only after a few minutes after ws is closed and terminated (even with force garbage collection)close
andterminate
do not always free the memoryReproducible in:
Steps to reproduce:
const server = restify.createServer()
server.get('/', async (req, res, next) => { const ws = new WebSocket('wss://api.bitfinex.com/ws/')
ws.on('error', () => {}) setTimeout(() => { ws.close() ws.terminate() }, 1000) res.send() next() })
server.listen(3000)