Tatva-Artha

meaning of "it"

Archive for the ‘passenger’ tag

Debugging Passenger Memory Issues

without comments

There was an interesting thread on ruby-passenger application server newsgroup recently: http://groups.google.com/group/phusion-passenger/browse_thread/thread/f48ad0eb018a2482

Here is my take away:

  # returns [class, count] tuples for all active records in the heap 
  def ar_space 
    GC.start 
    h = Hash.new(0) 
    ObjectSpace.each_object do |o| 
      next if o.__id__ == self.__id__ 
      next unless ActiveRecord::Base === o 
      h[o.class.to_s] += 1 
    end 
    return h.sort{|a,b| -(a[1]<=>b[1])} 
  end

Nifty little snippet to fetch number of active record objects on heap. I am guessing, incorporating this as Controller after_filter can help with cost of each request..

Written by Sharad

May 1st, 2011 at 1:05 pm

Posted in All

Tagged with , ,

Passenger, Apache, Ruby configuration

without comments

Installing passenger to work with apache for rails application is especially pleasant since it gives you direction to setup apache passenger module properly. I have done it several times and it has always worked. Recently I had to change the version of ruby that passenger uses and all I had to do is change the PassengerRuby directive in httpd.conf (or apache.conf) as follows:

#LoadModule passenger_module /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so
#PassengerRoot /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/gems/passenger-2.2.2
#PassengerRuby /opt/ruby-enterprise-1.8.6-20090421/bin/ruby

LoadModule passenger_module /opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.1.2/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby/lib/ruby/gems/1.8/gems/passenger-2.1.2
PassengerRuby /opt/ruby/bin/ruby

I am not sure if this is the recommended way but it worked for me.

Enjoy!

Written by Sharad

June 2nd, 2009 at 3:45 pm

Posted in All,Technology

Tagged with , ,