Skip to content

Instantly share code, notes, and snippets.

@authorNari
Created October 1, 2012 14:30
Show Gist options
  • Save authorNari/3812118 to your computer and use it in GitHub Desktop.
Save authorNari/3812118 to your computer and use it in GitHub Desktop.
# 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