Sha256: 234ccbeec021689a428d7fa449557d2e2f2741de06f933a2da14266e45628192

Contents?: true

Size: 915 Bytes

Versions: 5

Compression:

Stored size: 915 Bytes

Contents

#
# Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
# 

module Toaster
  class MemDump
    def self.print_dump(pattern=".*")
      Util.write("/tmp/foo.dump.out", "lala", true)
      res = {}
      count = 0
      ObjectSpace.each_object do |obj|
        cls = obj.class
        res[cls] = res[cls] ? res[cls] + 1 : 1
        count += 1
        print "Counted #{count} objects" if (count % 100000 == 0)
      end
      array = []
      res.each do |clazz,count|
        name = clazz.name
        if name.match(/#{pattern}/)
          array << [clazz,count]
        end
      end
      # sort by decreasing number of instances
      array.sort! { |o1,o2| o2[1] <=> o1[1] }
      array = array[0..50]
      out = ""
      array.each do |i|
        tmp = "#{i[0]} \t- Class #{i[0]}"
        out += tmp
        puts tmp
      end
      Util.write("/tmp/foo.dump.out", out, true)
      return array
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloud-toaster-1.1.6 lib/toaster/util/mem_dump.rb
cloud-toaster-1.1.5 lib/toaster/util/mem_dump.rb
cloud-toaster-1.1.4 lib/toaster/util/mem_dump.rb
cloud-toaster-1.1.3 lib/toaster/util/mem_dump.rb
cloud-toaster-1.1.2 lib/toaster/util/mem_dump.rb