Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak trying to memoize websockets #136

Open
AvnerCohen opened this issue Mar 4, 2015 · 3 comments
Open

Memory leak trying to memoize websockets #136

AvnerCohen opened this issue Mar 4, 2015 · 3 comments

Comments

@AvnerCohen
Copy link

I need to be able to publish data to specific websockets.
The full gist of it is: https://gist.github.com/AvnerCohen/72540e2dc13a56b4be87

Specifically I do something like:

  ws.onmessage do |msg|
      event_type, *data = msg.split(":")
      if event_type == 'typing'
        PublishMessage.do(WS_CLIENTS[data.first], "typing:#{data.last}")
        elsif event_type == 'connected'
          WS_CLIENTS_NAME_TO_SOCKET[ws.get_pid] = data.first
          WS_CLIENTS[data.first] = ws
        end
      end

and so, this line:

          WS_CLIENTS[data.first] = ws

Saves the websocket for later reference by username.

this is causing MRI to leak, no idea why, any alternative suggestion to overcome this?

@JokerCatz
Copy link

remove & clear cache when onclose?

@AvnerCohen
Copy link
Author

Sure, this is already happning:

      ws.onclose do
..
          WS_CLIENTS.delete(socket_entry)
..
      end

@JokerCatz
Copy link

hmm...I don't know why , & I fork em-websocket to support long-polling
https://github.com/JokerCatz/em-websocket/tree/long_polling_support
try it again? , it okay for our production , just overwrite the em-connection :)

@AvnerCohen AvnerCohen changed the title Memory leak trying to memaoize websockets Memory leak trying to memoize websockets Mar 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants