Create a gist now

Instantly share code, notes, and snippets.

# create objects that have deep references.
GC::Profiler.enable
depth = ARGV.pop
depth ||= 240
depth = depth.to_i
def make_deep_obj(parent, level, max)
if level > max
parent << "e".dup
return
end
parent << []
make_deep_obj(parent.last, level+1, max)
end
@roots = []
100000.times do
a = []
make_deep_obj(a, 0, depth)
@roots << a
end
GC::Profiler.report
p GC::Profiler.total_time
p GC.count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment