Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRubymark-sweep and GC.compactSingle-choice MCQ

After `GC.compact`, an object's address may change, yet `obj.object_id` returns the same value before and after. How does MRI keep object_id stable across compaction?

x = "a movable heap string here" oid = x.object_id GC.compact p x.object_id == oid # true