diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-11-30 11:50:11 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-11-30 11:50:11 +0000 |
commit | 68e4442ec720ca6730959681951f5862f97b5772 (patch) | |
tree | 95495e8e705a47ec20880318a0e82e1fb3b640e3 /activerecord/lib/active_record/aggregations.rb | |
parent | c5bdf6c5aee61848bee67b307287e2f28ddca173 (diff) | |
download | rails-68e4442ec720ca6730959681951f5862f97b5772.tar.gz rails-68e4442ec720ca6730959681951f5862f97b5772.tar.bz2 rails-68e4442ec720ca6730959681951f5862f97b5772.zip |
Fix memory leak in development mode
Keying these hashes by klass causes reloadable classes to never get
freed. Thanks to @thedarkone for pointing this out in
the comments on 221571beb6b4bb7437989bdefaf421f993ab6002.
This doesn't seem to make a massive difference to performance.
Benchmark
---------
require 'active_record'
require 'benchmark/ips'
class Post < ActiveRecord::Base
establish_connection adapter: 'sqlite3', database: ':memory:'
end
GC.disable
Benchmark.ips(20) do |r|
r.report { Post.connection }
end
Before
------
Calculating -------------------------------------
5632 i/100ms
-------------------------------------------------
218671.0 (±1.9%) i/s - 4364800 in 19.969401s
After
-----
Calculating -------------------------------------
8743 i/100ms
-------------------------------------------------
206525.9 (±17.8%) i/s - 4039266 in 19.992590s
Diffstat (limited to 'activerecord/lib/active_record/aggregations.rb')
0 files changed, 0 insertions, 0 deletions