Garbage Collector statistics

Have you ever wondering what is in the gabarge collector ? This little piece
of code may help :)

import string,gc

def debugGC(threshold=10):
    d = {}
    print "*" * 80
    for o in gc.get_objects():
        try:
            s = str(o.__class__)
            try:
                d[s] = d[s] + 1
            except  KeyError:
                d[s] = 1
        except AttributeError:
            pass # this is not a str_able object
    l = d.keys()
    l.sort()
    for key in l:
        if d[key] > threshold:
            print "%70s -> %d " % (key,d[key])
    print "*" * 80

Related posts :

admin August 22nd, 2003


One Response to “Garbage Collector statistics”

  1. micah alconcelon 30 Nov 2007 at 11:01 pm

    im model

Comments RSS

Leave a Reply