question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Socket.io memory doesn't drop of after clients disconnect

See original GitHub issue

I use the most simple example

var app = require('http').createServer(handler)
var io = require('socket.io')(app);
var fs = require('fs');

app.listen(1994);

function handler(req, res) {
    res.end('socket.io start')
}

io.on('connection', function(socket) {});

I use socket.io-client, create a 4k connections Then I closed the client, find memory doesn’t drop.

socket.on('disconnect', funtion() {
    delete io.sockets[socket.id];
    delete io.sockets.sockets[socket.id];
});

heapUsed decreased slightly rss and heapTotal without any change

SOS

The memory is cleaned up by the garbage collectors periodically. But I waited for half an hour, still no change. Can I only use global.gc() to forcibly reclaim memory it?

@nuclearace

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

18reactions
will-hangcommented, Apr 26, 2019

lol was this fixed? i’m scared to use sockets.io because i keep hearing about this issue

8reactions
darrachequesnecommented, Jan 12, 2017

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Socket.io memory doesn't drop of after clients disconnect
I have memory leaks in my Socket.io 0.9.16 and Node 0.10.12 / 0.10.13 application. After connecting some clients the RSS memory increases but ......
Read more >
Troubleshooting connection issues | Socket.IO
You are trying to reach a plain WebSocket server; The server is not reachable; The client is not compatible with the version of...
Read more >
Memory usage | Socket.IO
The memory usage of the Socket.IO server heavily depends on the memory usage of the underlying WebSocket server implementation. The chart below ...
Read more >
Performance tuning - Socket.IO
Here are some tips to improve the performance of your Socket.IO server:
Read more >
Server options - Socket.IO
The server and the client values must match (unless you are using a ... Default value: require("socket.io-adapter") (in-memory adapter, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found