This is a simple tool to enable the object allocation tracer. When you have an object of unknown provenance, you can use this to investigate where the object in question is created.
This is only for debugging purpose. Do not use this in production. Require'ing this file immediately starts tracing the object allocation, which brings a large performance overhead.
Add `require “objspace/trace”` into your code (or add `-robjspace/trace` into the command line)
`p obj` will show the allocation site of `obj`
Note: This redefines `Kernel#p` method, but not `Object#inspect`.
1: require "objspace/trace" 2: 3: obj = "str" 4: 5: p obj #=> "str" @ test.rb:3