Last active
December 11, 2015 20:08
-
-
Save dpaluy/4652948 to your computer and use it in GitHub Desktop.
Debuggin Ruby
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
GC.enable_stats if defined?(GC) && GC.respond_to?(:enable_stats) | |
GC.start # clean up heap | |
# dump it, including class names of heap objects | |
GC.dump_file_and_line_info(filename: "heap.dump", include_class_names: true) | |
stat_string = "allocated: #{GC.allocated_size/1024}K total in #{GC.num_allocations} allocations, GC calls: #{GC.collections}, GC time: #{GC.time / 1000} msec" |
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
rvm get stable | |
find $rvm_path/patch* -type f # See all your patches | |
rvm install 1.9.3 --patch railsexpress -C --enable-gcdebug -n gcdebug |
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
def get_object_stats | |
return_value = Hash.new | |
ObjectSpace::each_object(Object) {|my_object| | |
unless return_value[my_object.class.to_s.downcase].nil? | |
return_value[my_object.class.to_s.downcase][:count] += 1 | |
else | |
return_value[my_object.class.to_s.downcase] = Hash.new | |
return_value[my_object.class.to_s.downcase][:name] = my_object.class | |
return_value[my_object.class.to_s.downcase][:count] = 1 | |
end | |
} | |
return_value.sort_by {|k,v| -v[:count]} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another useful patch:
rvm install 1.9.3 --with-gcc=gcc --patch gcdata -n gcdata