Created
February 16, 2019 08:19
-
-
Save yhara/431c4845efd561d3647f55d7493daafd to your computer and use it in GitHub Desktop.
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
gem 'activerecord', '5.2.0' | |
require 'active_record' | |
p AR: ActiveRecord.version | |
module ActiveRecord | |
module ConnectionAdapters | |
class ConnectionHandler | |
def self.create_owner_to_pool | |
Concurrent::Map.new(initial_capacity: 2) do |h, k| | |
# Discard the parent's connection pools immediately; we have no need | |
# of them | |
ConnectionHandler.discard_unowned_pools(h) | |
h[k] = Concurrent::Map.new(initial_capacity: 2) | |
end | |
end | |
def initialize | |
# These caches are keyed by spec.name (ConnectionSpecification#name). | |
@owner_to_pool = ConnectionHandler.create_owner_to_pool | |
# Backup finalizer: if the forked child never needed a pool, the above | |
# early discard has not occurred | |
ObjectSpace.define_finalizer self, ConnectionHandler.unowned_pool_finalizer(@owner_to_pool) | |
end | |
end | |
end | |
end | |
ActiveRecord::ConnectionAdapters::ConnectionHandler.new | |
10.times{ GC.start } | |
p ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::ConnectionHandler).to_a |
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
source 'https://rubygems.org' | |
gem 'activerecord', '5.2.0' |
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
GEM | |
remote: https://rubygems.org/ | |
specs: | |
activemodel (5.2.0) | |
activesupport (= 5.2.0) | |
activerecord (5.2.0) | |
activemodel (= 5.2.0) | |
activesupport (= 5.2.0) | |
arel (>= 9.0) | |
activesupport (5.2.0) | |
concurrent-ruby (~> 1.0, >= 1.0.2) | |
i18n (>= 0.7, < 2) | |
minitest (~> 5.1) | |
tzinfo (~> 1.1) | |
arel (9.0.0) | |
concurrent-ruby (1.1.4) | |
i18n (1.5.3) | |
concurrent-ruby (~> 1.0) | |
minitest (5.11.3) | |
thread_safe (0.3.6) | |
tzinfo (1.2.5) | |
thread_safe (~> 0.1) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
activerecord (= 5.2.0) | |
BUNDLED WITH | |
1.17.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment