title: Memory usage increase with Ruby 2.1 versus Ruby 2.0 or 1.9
body: <p>I recently deployed an upgrade of Ruby from 2.0 to 2.1.5 to my Heroku web application, and I am consistently hitting memory quota errors now, whereas with 2.0 and 1.9 this never happened.  There is a limit of 512MB for a normal Heroku Dyno, and I am running 2 processes with Unicorn, along with one thread with Sidekiq across two dynos.</p>
  
  <p>After reading <a href="https://stackoverflow.com/questions/24568467/phusion-passenger-memory-consumption-increase-from-1-9-3-system-to-2-1-2-rvm/24569004">Phusion Passenger memory consumption increase from 1.9.3 (system) to 2.1.2 (RVM) on Ubuntu</a>, I tried setting the environment variable <code>RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR</code> to 0.9 to disable generational garbage collector, and it did improve memory consumption somewhat, but still left me nowhere near what 2.0 or 1.9 consumed.  As memory right now is my primary concern, I would like to see if I can fix this problem with ruby 2.1.x instead of reverting to 2.0.</p>
  
  <p>Here are some graphs demonstrating the problem:</p>
  
  <p><strong>At just before 2pm, I downgraded to Ruby 2.0.0-p598 to Ruby 2.1.5 and the memory issues were resolved and remained under the limit.</strong></p>
  
  <p><img src="https://i.stack.imgur.com/smIBp.png" alt="moving from 2.1.5 to 2.0.0 Heroku">
  <img src="https://i.stack.imgur.com/0dac8.png" alt="moving from 2.1.5 to 2.0.0 New Relic"></p>
  
  <p><strong>Then later, I tried upgrading to Ruby 2.1.5 but setting the environment variable <code>RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR</code> to 0.9.  As you can see, the memory usage is slightly better than the original 2.1.5 graph, but still breaches the memory quota.</strong></p>
  
  <p><img src="https://i.stack.imgur.com/Ct9Gh.png" alt="moving from 2.0.0 to 2.1.5 with &lt;code&gt;RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR&lt;/code&gt; to 0.9 Heroku">
  <img src="https://i.stack.imgur.com/pCA5L.png" alt="moving from 2.0.0 to 2.1.5 with &lt;code&gt;RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR&lt;/code&gt; to 0.9 New Relic"></p>