Feature #17762 ยป objspace-trace.patch
ext/objspace/lib/objspace/trace.rb | ||
---|---|---|
require 'objspace.so'
|
||
module Kernel
|
||
define_method(:p) do |*objs|
|
||
objs.each do |obj|
|
||
file = ObjectSpace.allocation_sourcefile(obj)
|
||
line = ObjectSpace.allocation_sourceline(obj)
|
||
if file
|
||
puts "#{ obj.inspect } @ #{ file }:#{ line }"
|
||
else
|
||
puts obj.inspect
|
||
end
|
||
end
|
||
end
|
||
end
|
||
ObjectSpace.trace_object_allocations_start
|
||
warn "objspace/trace is enabled"
|