Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.