module function ObjectSpace.#trace_object_allocations

trace_object_allocations { ... }[permalink][rdoc] [added by objspace]

与えられたブロック内でオブジェクトのトレースを行います。 



require 'objspace'

class C
  include ObjectSpace

  def foo
    trace_object_allocations do
      obj = Object.new
      p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}"
    end
  end
end

C.new.foo #=> "objtrace.rb:8"