method

allocation_generation

Importance_1
v2_6_3 - Show latest stable - 0 notes - Class: ObjectSpace
allocation_generation(p1) public

Returns garbage collector generation for the given object.

class B
  include ObjectSpace

  def foo
    trace_object_allocations do
      obj = Object.new
      p "Generation is #{allocation_generation(obj)}"
    end
  end
end

B.new.foo #=> "Generation is 3"

See ::trace_object_allocations for more information and examples.

Show source
Register or log in to add new notes.