Skip to content

Instantly share code, notes, and snippets.

@mustmodify
Last active February 19, 2019 02:37
Show Gist options
  • Save mustmodify/29ea901474a8388c3cf698020c742df6 to your computer and use it in GitHub Desktop.
Save mustmodify/29ea901474a8388c3cf698020c742df6 to your computer and use it in GitHub Desktop.
require 'allocation_stats'
stats = AllocationStats.trace { x = 'stuff'; String.new(x) }
puts stats.allocations(alias_paths: true).to_text
puts
stats2 = AllocationStats.trace { String.new("stuff")}
puts stats2.allocations(alias_paths: true).to_text
puts
stats3 = AllocationStats.trace { x = "stuff" }
puts stats3.allocations(alias_paths: true).to_text
jw@logopolis:/projects/saw/castle$ ruby object_check.rb
sourcefile sourceline class_path method_id memsize class
--------------- ---------- ---------- --------- ------- ------
object_check.rb 3 Class new 40 String
object_check.rb 3 40 String
sourcefile sourceline class_path method_id memsize class
--------------- ---------- ---------- --------- ------- ------
object_check.rb 6 Class new 40 String
object_check.rb 6 40 String
sourcefile sourceline class_path method_id memsize class
--------------- ---------- ---------- --------- ------- ------
object_check.rb 9 40 String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment