Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > objspaceライブラリ > ObjectSpaceモジュール > allocation_sourcefile
allocation_sourcefile(object) -> String
[permalink][rdoc] [added by objspace]
objectの元となったソースファイル名を返します。
require 'objspace'
ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "file:#{ObjectSpace::allocation_sourcefile(obj)}" # => file:test.rb
ObjectSpace::trace_object_allocations_stop
[SEE_ALSO] ObjectSpace.#trace_object_allocations_start, ObjectSpace.#trace_object_allocations_stop