Created
July 29, 2011 05:04
-
-
Save ryandotsmith/1113166 to your computer and use it in GitHub Desktop.
I am using this to profile my workers (queue_classic)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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