Using Rails 3.0.7, REE 1.8.7.
I want to run code (specifically, Garbage Collection) in Rails after the response has been sent to the browser.
Is there a way to patch into Rails/Rack/something so that I can call GC.start right after the response is sent to the browser from the controller?
*Note: This is not a situation where I want to use delayed_job or resque. I am aware of those tools already and they are not appropriate for this use case.*
This one-line patch to passenger allows you to run GC between requests. After implementing it, we saw our GC execution time (as reported by NewRelic) drop by about 40%. Individual results may vary. :)
Thanks to this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With