How to get object reference by memory address (hexadecimal number in inspect result)

  1. calculate object_id from memory address object_id returns half the object’s memory address, so you need to multiply by 2 to get the actual address. (Vice versa, divide memory address by 2 to get object_id)

  2. get reference of object by object_id obj = ObjectSpace._id2ref(object_id)

  3. inspect referenced object obj.inspect


Object address in Ruby Can I or SHOULD I find an object by the object_id attribute in ruby?