Skip to content

Instantly share code, notes, and snippets.

@andys
Created July 1, 2011 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andys/1057780 to your computer and use it in GitHub Desktop.
Save andys/1057780 to your computer and use it in GitHub Desktop.
Disabling Garbage Collection around every rails request
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