def dump_object_counts
      log GC.stat.inspect
      counts = {}
      total = 0
      ObjectSpace.each_object do |o|
        count = counts[o.class.name] || 0
        counts[o.class.name] = count + 1
        total += 1
      end
      top = 10
      log "#{total} objects. top #{top}:"
      counts.sort_by { |name, count| count }.reverse.each_with_index do |(name, count), i|
        if i < top
          diff = ""
          if last = @last_counts && @last_counts[name]
            diff = " (#{'%+d' % (count - last)})"
          end
          log "   #{count} #{name}#{diff}"
        end
      end
      @last_counts = counts
      log GC.stat.inspect
    rescue => e
      log "Error while counting objects: #{e}"
    end
def dump_object_counts
      log GC.stat.inspect
      counts = {}
      total = 0
      ObjectSpace.each_object do |o|
        count = counts[o.class.name] || 0
        counts[o.class.name] = count + 1
        total += 1
      end
      top = 10
      log "#{total} objects. top #{top}:"
      counts.sort_by { |name, count| count }.reverse.each_with_index do |(name, count), i|
        if i < top
          diff = ""
          if last = @last_counts && @last_counts[name]
            diff = " (#{'%+d' % (count - last)})"
          end
          log "   #{count} #{name}#{diff}"
        end
      end
      @last_counts = counts
      log GC.stat.inspect
    rescue => e
      log "Error while counting objects: #{e}"
    end
Private.