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.

Empty rooms aren't deleted

See original GitHub issue

I noticed a possible memory leak, so I tested by connecting to my server from about a dozen client webpages and repeatedly refreshing them. Memory usage increased with each refresh and never fell back to pre-refresh levels.

Turns out the unique rooms that are created for new connections aren’t getting deleted — they remain in the room list despite becoming empty upon refresh. Empty rooms are supposed to be destroyed automatically, so I don’t know what’s going on, but it might be why memory usage keeps rising.

I tried explicitly deleting these rooms when a client disconnects. This removes them from the room list, but memory usage seems unaffected. I might be doing it wrong:

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

Does this seem strange to anyone else? Is there another potential reason for the memory leak?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:22 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ryanhestincommented, Nov 25, 2014

I see this has been closed, but it does not appear to be resolved. Can we get some sort of comment on this please?

Will manually doing

socket.join(<room string>)

not auto delete a room upon disconnect?

Does this demand manual deletion? I’m seeing in my logs of a rather basic chat server that huge stacks of rooms are being kept in even after disconnection (force OR clean disconnect).

0reactions
darrachequesnecommented, Oct 7, 2017

@ncacace I think your use case is a bit too specific to be implemented in socket.io internals.

The room is destroyed once the last element leaves it (https://github.com/socketio/socket.io-adapter/blob/1.1.1/index.js#L81).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Photon does not delete empty rooms
To be clear: photon rooms are removed automatically. There is a RoomProperty named EmptyRoomTtl that determines the minimum amount of time that ...
Read more >
node.js - are socket io rooms automaticaly destroyed if empty?
I have 2 questions: - When a room is empty, is it automatically destoyed unbtil recreated? and if it is not destroyed automaticaly, ......
Read more >
Delete a Room | Revit 2018 - Autodesk Knowledge Network
To delete multiple rooms, do the following: Click Modify Schedule/Quantities tab Filter Not Placed & Unenclosed Items panel (Isolate).
Read more >
Remove Not Placed Rooms by Dynamo - YouTube
You can make your own code or use mine for a coffee. :)
Read more >
How to creeate and delete room dynamicaly - Google Groups
So I need create and delete rooms in my chat server. Is it possible to do it ? ... So only the clients...
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