Created
July 1, 2011 02:50
-
-
Save andys/1057780 to your computer and use it in GitHub Desktop.
Disabling Garbage Collection around every rails request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
around_filter :disable_garbage_collection | |
def disable_garbage_collection | |
unless @use_garbage_collection | |
GC.disable | |
begin | |
yield | |
ensure | |
GC.enable | |
GC.start | |
end | |
else | |
yield | |
end | |
end | |
# turn this on with: | |
# prepend_around_filter :leave_garbage_collection_on | |
def leave_garbage_collection_on | |
@use_garbage_collection = true | |
yield | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment