Hi All,
I tracked down a memory leak (600~1000kb per request for our setup) originated from this commit,
commit ca6d71753f3a2e8a0a29108b7c55ba3b7c8cd943
Deprecate allow_concurrency and make it have no effect
It's a commit that deprecated `'allow_concurrency', but looks like it kept all them mechanism intact (which is kinda weird). The patch below stops the leaking, but I don't really know why Thread.current is still in there, or why it's leaking.
It surprised me that it's from so far back.
Howard
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/ active_record/base.rb index a36a137..df31a3d 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2023,7 +2023,8 @@ module ActiveRecord #:nodoc: end
def scoped_methods #:nodoc: - scoped_methods = (Thread.current[:scoped_methods] ||= {}) + @scoped_methods ||= {} + scoped_methods = @scoped_methods scoped_methods[self] ||= end