https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112020-05-07T16:03:28ZRuby Issue Tracking SystemRuby master - Feature #16761: Add an API to move the entire heap, as to make testing GC.compact compatibility easierhttps://redmine.ruby-lang.org/issues/16761?journal_id=854282020-05-07T16:03:28Ztenderlovemaking (Aaron Patterson)tenderlove@ruby-lang.org
<ul></ul><p>We currently have this functionality, but the API isn't as nice as what you propose (and the naming isn't great either).</p>
<p>You can do <code>GC.verify_compaction_references(toward: :empty, double_heap: true)</code>. It will double the size of the heap, then pack towards empty pages which will ensure that any object that can move will move. Maybe we should change the name to <code>debug_compaction</code> with options?</p>
<p>I'd like to add some other debugging options. For example, if an object doesn't update references correctly another object can be allocated in to the slot. E.g:</p>
<p>A -> B<br>
C -> B</p>
<p>Maybe B moves and C updates it's references but A does not. If a new object D is allocated in the slot where B <em>used</em> to live, then we could end up with:</p>
<p>A -> D<br>
C -> B</p>
<p>I have a way to debug this locally, but no good solution for upstream yet. It's probably off topic for this issue, but my point is that we have multiple techniques for debugging this so I think a method that takes options is best</p>