Using out of band GC via OobGC.
require_dependency 'unicorn/oob_gc'
GC.disable # Don't run GC during requests
use(Unicorn::OobGC, 40) # Only GC once every n requests
# UnicornSlayer kills overgrown workers
require_dependency 'unicorn/unicorn_slayer.rb'
use(UnicornSlayer::MaxRequests, 1000)
use(UnicornSlayer::Oom, 400 * 1024, 1)
# GC ever two requests that hit /expensive/foo or /more_expensive/foo
# in your app. By default, this will GC once every 5 requests
# for all endpoints in your app
# from http://unicorn.bogomips.org/Unicorn/OobGC.html
use(Unicorn::OobGC, 2, %r{\A/(?:expensive/foo|more_expensive/foo)})