title: Increased Memory Size after converting to Ruby Enterprise 1.8.7
body: <p>When upgrading from Ruby 1.8.6 to Ruby Enterprise 1.8.7 p334, the memory size has nearly doubled.  This has occurred in every one of the five Fedora 8 servers we upgraded.  We run Rails 1.2.6 with Passenger 3.0.4.</p>
  
  <p>Munin gets the memory size for every process by summing the vsz and rsz columns from <code>$ ps axo pid,comm,pmem,vsz,rsz</code>.  (The virtual memory size and resident memory size both increase the same amount)</p>
  
  <p>I realize that these columns generally overstate the amount of memory actually used by the processes, but if this was used to measure 1.8.6 and then 1.8.7 REE, they should be equally bloated, and therefore still comparable.  </p>
  
  <p>In addition, the committed memory for the machine (as listed in /proc/memstat) is now regularly overcommitting, which is new.  The amount committed memory has increased significantly, and it looks like we're now into swap space.</p>
  
  <p>We have not yet tuned the garbage collection, but I can't see how that would affect the overall memory footprint.</p>
  
  <p>I have turned on the GC.copy_on_write_friendly variable as recommended by the Phusion FAQ.</p>
  
  <p>What is the explanation for this 100% increase in memory usage and how can I fix it?  Any ideas on how to fix, or even better monitor/debug, are appreciated.</p>
  
  <p>Thanks.</p>
  
  <p><strong>---UPDATE</strong></p>
  
  <p>In order to check performance, I have decreased the number of running instances (PassengerMaxPoolSize) from 12 to 10 on one server.  On another, I have raised the PassengerPoolIdleTime to 15 minutes.  I have a third that is being used as a control.</p>
  
  <p>I'm considering putting a non-enterprise version 1.8.7p334 on a server to see if it's 1.8.7 or the Enterprise Edition.  </p>
  
  <p>Anyone else have any experience with this type of issue?</p>
  
  <p>Looking at the individual Rails processes, they are about 120MB per process in 1.8.6, and 175MB/process in REE 1.8.7, as stated by passenger-memory-stats.</p>
  
  <p><strong>---UPDATE 2</strong></p>
  
  <p>I put MRI 1.8.7 on a server for comparison to REE 1.8.7.  The results were worse, including higher memory resident size number and passenger-memory-stats.  Of course, swapping started.</p>
  
  <p>This is leading me to believe that 1.8.7 simply has a larger footprint than 1.8.6.</p>
  
  <p><strong>---UPDATE 3</strong></p>
  
  <p>I put MRI 1.8.7 on a server, it was much worse that MRI 1.8.6 in terms of memory usage, so I immediately went back to MRI 1.86.</p>
  
  <p>I've run an average of Rails process size, as listed by passenger-memory-stats.  The REE 1.8.7 processes were 73 MB larger, which seems rather large.</p>
  
  <p>This means that I need to have significantly less processes running to fit in the same memory footprint.  </p>
  
  <p>Will see how they perform with fewer processes.  I'm also starting the GC tuning.</p>
  
  <p><strong>---UPDATE 4</strong></p>
  
  <p>Seems Ruby 1.8.7 does not support Rails 1.2.6.  The first officially supported version of 1.8.7 is Rails 2.1.  We'll know after the upgrade if that's the root of the problem.</p>