Skip to content

Instantly share code, notes, and snippets.

@bil-bas
Created August 21, 2012 23:26
Show Gist options
  • Save bil-bas/3420409 to your computer and use it in GitHub Desktop.
Save bil-bas/3420409 to your computer and use it in GitHub Desktop.
Count objects.
# List all objects where there are > 1 instance
h = Hash.new(0)
ObjectSpace.each_object {|o| h[o.class] += 1 }
h.select {|k, v| v > 1 }.sort_by {|k, v| -v }.each {|k, v| puts "#{k}: #{v}" };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment