Last active
March 27, 2025 01:56
-
-
Save schneems/003de3b80e6b983c84ebc7273fd60947 to your computer and use it in GitHub Desktop.
trace where Ruby objects come from with this handy bash 3 liner
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
echo 'require "objspace"; ObjectSpace.trace_object_allocations_start; Kernel.send(:define_method, :sup) do |obj| ; puts "#{ ObjectSpace.allocation_sourcefile(obj) }:#{ ObjectSpace.allocation_sourceline(obj) }"; end' > tmp/tmp-gemfile | |
cat Gemfile >> tmp/tmp-gemfile | |
cat tmp/tmp-gemfile > Gemfile | |
# $ bundle exec irb | |
# irb(main):001:0> require 'rails' | |
# => true | |
# irb(main):002:0> sup(Rails) | |
# /Users/richardschneeman/.gem/ruby/2.4.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment