Skip to content

Instantly share code, notes, and snippets.

@dpoggi
Created September 23, 2015 20:29
Show Gist options
  • Save dpoggi/82ff2df494b9696bdedc to your computer and use it in GitHub Desktop.
Save dpoggi/82ff2df494b9696bdedc to your computer and use it in GitHub Desktop.
Save the first 10,000 objects in Ruby's VM to a text file for inspection
#!/usr/bin/env ruby
things = (0..10000).map do |n|
begin
ObjectSpace._id2ref(n)
rescue
nil
end
end
File.open('things.txt', 'w') do |f|
things.compact.each { |thing| f.puts(thing) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment