require 'session' # gem install session module Process # # this uses the same shell over and over to avoid the overhead of process # creation - you still create 'ps', but not an instance of /bin/sh # def self.size pid = Process.pid @sh = Session.new @sh.execute "ps wwwaux -p #{ pid }", :stdout => stdout=[] vsize, rsize = stdout.last.split(%r/\s+/)[4,2] end end p Process.size