code: def do_gc(self, args):
          
  
          ### humm...
          instance_type = getattr(types, 'InstanceType', object)
  
          # snapshot of counts
          type2count = {}
          type2all = {}
          for o in gc.get_objects():
              if type(o) == instance_type:
                  type2count[o.__class__] = type2count.get(o.__class__,0) + 1
                  type2all[o.__class__] = type2all.get(o.__class__,0) + sys.getrefcount(o)
  
          # count the things that have changed
          ct = [ ( t.__module__
              , t.__name__
              , type2count[t]
              , type2count[t] - self.type2count.get(t,0)
              , type2all[t] - self.type2all.get(t,0)
              ) for t in type2count.iterkeys()
              ]
  
          # ready for the next time
          self.type2count = type2count
          self.type2all = type2all
  
          fmt = "%-30s %-30s %6s %6s %6s\n"
          self.stdout.write(fmt % ("Module", "Type", "Count", "dCount", "dRef"))
  
          # sorted by count
          ct.sort(lambda x, y: cmp(y[2], x[2]))
          for i in range(min(10,len(ct))):
              m, n, c, delta1, delta2 = ct[i]
              self.stdout.write(fmt % (m, n, c, delta1, delta2))
          self.stdout.write("\n")
  
          self.stdout.write(fmt % ("Module", "Type", "Count", "dCount", "dRef"))
  
          # sorted by module and class
          ct.sort()
          for m, n, c, delta1, delta2 in ct:
              if delta1 or delta2:
                  self.stdout.write(fmt % (m, n, c, delta1, delta2))
          self.stdout.write("\n")
docs: gc - print out garbage collection information