-
-
Save michaeldwan/1343347 to your computer and use it in GitHub Desktop.
I am using this to profile my workers (queue_classic)
This file contains hidden or 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 | |
MAC = RUBY_PLATFORM =~ /darwin/ | |
def log | |
"memory=#{real_mem_size} ruby_objects=#{num_objects}" | |
end | |
def real_mem_size | |
mb = (MAC ? `ps -o rss -p #{$$}` : `ps -o rsz #{$$}`).split("\n")[1].to_f / 1024.0 | |
mb = mb.round(1) | |
"#{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