Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created July 29, 2011 05:04
Show Gist options
  • Save ryandotsmith/1113166 to your computer and use it in GitHub Desktop.
Save ryandotsmith/1113166 to your computer and use it in GitHub Desktop.
I am using this to profile my workers (queue_classic)
module Memstat
extend self
def puts
"memory=#{real_mem_size} ruby_objects=#{num_objects}"
end
def real_mem_size
mb = `ps -o rsz #{$$}`.split("\n")[1].to_f / 1024.0
mb = mb.round(-2) # nearest 100 (i.e. 60.round(-2) == 100)
"#{mb}MB"
end
def num_objects
ObjectSpace.count_objects[:TOTAL]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment