-
-
Save matthewd/3d78bae0ebebdc20981e 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
require 'active_record' | |
Bundler.require :default | |
require 'objspace' | |
ObjectSpace.trace_object_allocations_start | |
def iter n | |
if n > 0 | |
1.times{ | |
iter(n-1) | |
} | |
else | |
# null code | |
end | |
end | |
def gc | |
iter(100) | |
GC.start | |
GC.start | |
end | |
class TestClass | |
def foo | |
require 'net/telnet' | |
end | |
end | |
def do_the_thing | |
x = TestClass.new | |
x.foo | |
nil | |
end | |
do_the_thing | |
# This fixes it: | |
#require 'net/smtp' | |
gc | |
n = Hash.new(0); ObjectSpace.each_object(TestClass) {|o| n[o.class.name] += 1 }; p Hash[n.sort] | |
gc | |
puts ObjectSpace.dump_all.path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment