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():
            s = str(o.__class__)
                d[s] = d[s] + 1
            except  KeyError:
                d[s] = 1
        except AttributeError:
            pass # this is not a str_able object
    l = d.keys()
    for key in l:
        if d[key] > threshold:
            print "%70s -> %d " % (key,d[key])
    print "*" * 80

Related Posts

One thought on “Garbage Collector statistics

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>