Skip to content

Commit

Permalink
Add GC.verify_compaction_references
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Dec 10, 2023
1 parent aa134bc commit f0603a7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,21 @@ def prepare_table
session.execute(statement)
end

def verify_gc_compaction
# This method was added in Ruby 3.0.0. Calling it this way asks the GC to
# move objects around, helping to find object movement bugs.
if defined?(GC.verify_compaction_references) == 'method'
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')
GC.verify_compaction_references(expand_heap: true, toward: :empty)
else
GC.verify_compaction_references(double_heap: true, toward: :empty)
end
end
end

at_exit do
verify_gc_compaction
end

prepare_keyspace
prepare_table

0 comments on commit f0603a7

Please sign in to comment.