Skip to content

Instantly share code, notes, and snippets.

@benders
Created January 20, 2011 21:16
Show Gist options
  • Save benders/788695 to your computer and use it in GitHub Desktop.
Save benders/788695 to your computer and use it in GitHub Desktop.
Rake task to set GC params before running tests
namespace :test do
desc "Tune GC environment variables for test running"
task :gc do
# Requires REE or a Ruby patched to allow GC tuning
# Credit to Darren Boyd at ZenDesk for the settings
ENV['RUBY_HEAP_MIN_SLOTS']='500000'
ENV['RUBY_HEAP_SLOTS_INCREMENT']='500000'
ENV['RUBY_HEAP_SLOTS_GROWTH_FACTOR']='1'
ENV['RUBY_GC_MALLOC_LIMIT']='100000000'
ENV['RUBY_HEAP_FREE_MIN']='500000'
end
end
# Hook the GC task before the common db prep prereq for all tests
Rake::Task['db:test:prepare'].enhance ['test:gc']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment