imanel/websocket-rack

memory leak?

mscherer82 opened this issue · 3 comments

Hello,

I've run some memory test with an empty implementation of the websocket rack

class MyApp < Rack::WebSocket::Application

  def initialize  
    super
  end

  def on_open(env)
    puts "on open"
  end

  def on_message(env, msg)
    puts msg
  end

  def on_close(env)
    puts "on close"    
  end
end

and a client which is building and closing a connection to this server every few seconds. I've seen that the memory of the process increases by 1 MB on every 100 connections. I'm using ruby 1.9.2p180 with thin 1.3.1 and eventmachine-1.0.0.beta.4.

Interesting - I'm using ruby 1.9.2p136, thin 1.2.11 and eventmachine 1.0.0.beta.3 few months, sometimes up to 1'000 connections/day and it holds ~30 MB of memory. Are you able to reach more than 100 MB memory used by thin? Until then GC should be called. If so then we will need to test WebSocket-Rack with other versions of ruby/thin/eventmachine and find which one make problems :)

ok, I've called the GC by my own every 100 requests. I've run the tests again with thin 1.2.11 + EM 0.12.10 and thin 1.3.1 + EM 1.0.0.beta.4 and got the same results. The memory gains slower as I reported before. It's only 1MB every 300 connections. Maybe I can test it tomorrow on another machine with other ruby versions.

Still could not reproduce - if this will show again then I will reopen.