public
Last active

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
commit b67ed0cc42e751a99f308f3b61604208fb0f5d74
Author: Brian Lopez <seniorlopez@gmail.com>
Date: Thu Feb 18 13:00:09 2010 -0800
 
fix memory leaks in ActionPack when cache_classes is disabled
 
diff --git a/actionpack/lib/abstract_controller/localized_cache.rb b/actionpack/lib/abstract_controller/localized_cache.rb
index 5e3efa0..5f81674 100644
--- a/actionpack/lib/abstract_controller/localized_cache.rb
+++ b/actionpack/lib/abstract_controller/localized_cache.rb
@@ -3,7 +3,8 @@ module AbstractController
@hash_keys = Hash.new {|h,k| h[k] = Hash.new {|sh,sk| sh[sk] = {} } }
def self.get(klass, formats, locale)
- @hash_keys[klass][formats][locale] ||= new(klass, formats, locale)
+ hash_key = Rails.application.config.cache_classes ? @hash_keys[klass][formats] : {}
+ hash_key[locale] ||= new(klass, formats, locale)
end
attr_accessor :hash
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 4fd37e7..b9c454b 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -82,7 +82,8 @@ module ActionController
@@endpoints = Hash.new {|h,k| h[k] = Hash.new {|sh,sk| sh[sk] = {} } }
def self.for(controller, action, stack)
- @@endpoints[controller][action][stack] ||= begin
+ endpoint = Rails.application.config.cache_classes ? @@endpoints[controller][action] : {}
+ endpoint[stack] ||= begin
endpoint = new(controller, action)
stack.build(endpoint)
end
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb
index 8b6dce0..67f36b4 100644
--- a/actionpack/lib/action_view/render/partials.rb
+++ b/actionpack/lib/action_view/render/partials.rb
@@ -180,7 +180,7 @@ module ActionView
def initialize(view_context, options, block)
@view = view_context
- @partial_names = PARTIAL_NAMES[@view.controller.class]
+ @partial_names = Rails.application.config.cache_classes ? PARTIAL_NAMES[@view.controller.class] : {}
key = Thread.current[:format_locale_key]
@templates = TEMPLATES[key] if key
gistfile2.txt
1 2 3 4 5 6
# add to the end of your controller to see the leaks
 
Rails.logger.debug ActionView::Partials::PartialRenderer::PARTIAL_NAMES.inspect
Rails.logger.debug AbstractController::HashKey.instance_variable_get(:@hash_keys).inspect
Rails.logger.debug ActionController::Metal::ActionEndpoint.send(:class_variable_get, :@@endpoints).inspect
Rails.logger.debug ObjectSpace.each_object(Class).map{|c| c if c.ancestors.find{|o| o.to_s == 'ApplicationController'}}.compact.size

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.