Skip to content

Instantly share code, notes, and snippets.

@Fryguy
Created October 13, 2015 00:54
Show Gist options
  • Save Fryguy/79620f44519193477923 to your computer and use it in GitHub Desktop.
Save Fryguy/79620f44519193477923 to your computer and use it in GitHub Desktop.
simple irb allocations
irb(main):001:0> require 'objspace'
=> true
irb(main):002:0> GC.start
=> nil
irb(main):003:0> GC.start
=> nil
irb(main):004:0> ObjectSpace.dump_all
=> #<File:/var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-1kakmc5.json>
irb(main):005:0> ObjectSpace.trace_object_allocations_start
=> nil
irb(main):006:0> x = []
=> []
irb(main):007:0> 10.times { 10.times { x << rand.to_s }; GC.start }
=> 10
irb(main):008:0> GC.start
=> nil
irb(main):009:0> ObjectSpace.dump_all
=> #<File:/var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-14sgquk.json>
$ wc -l /var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-1kakmc5.json
28400 /var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-1kakmc5.json
$ wc -l /var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-14sgquk.json
13596 /var/folders/y3/p3qvt8mj7v36kg5m6_mfdfgm0000gn/T/rubyheap20151012-93687-14sgquk.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment