possible memory leak in thin/sinatra stack #860

rakaur opened this Issue May 6, 2011 · 5 comments


None yet

2 participants


Running a simple "one-line" Sinatra app leaks memory slowly. According to memory dumps it creates a lot of Arrays. It could be sinatra, tilt, thin, eventmachine, or anything in the gems that sinatra and thin utilize.

To reproduce, gem install sinatra and gem install thin. A simple sinatra app will do:


class App < Sinatra::Base
  get '/' do
    "hello world"


require 'sinatra'
require './app'
run App

Then run with thin. Sit back and watch the memory leak.


It seems that it is not thin, as it happens on WEBrick with a small variation in the memory dump details.

Rubinius member
rkh commented May 7, 2011

Seems to be a Rubinius bug that has nothing to do with the Rack handler, here is a test to reproduce it: https://github.com/rkh/sinatra/compare/rbx-leak
No issues on 1.8.7 and 1.9.2.


I went ahead and ran the same set up except on ree. I came back in a little over 24 hours and it was using more than half a gigabyte of memory. I switched it to unicorn on ree instead of thin on ree and the memory usage is fine after 24 hours. I'm going to try it with rbx on unicorn. Makes me think thin/eventmachine has to have something to do with it?


I've been running this on rbx+unicorn for 48 hours now and memory is better. Now I really think this has to be sinatra/tilt and the reason I saw it with WEBrick too is probably just because WEBrick sucks...


I think this is related to #872 and the leak is in EventMachine, used by thin.

@rakaur rakaur closed this May 13, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment