Garbage Collection (GC Module)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zhu_dave
    New Member
    • Sep 2005
    • 6

    Garbage Collection (GC Module)

    Hi,

    I use the following code to get some stats about memory usage:

    objs = gc.get_objects( )
    classes = len([obj for obj in objs if inspect.isclass (obj)])
    functions = len([obj for obj in objs if inspect.isrouti ne(obj)])
    modules = len([obj for obj in objs if inspect.ismodul e(obj)])
    dicts = len([obj for obj in objs if type(obj) == types.DictType])
    lists = len([obj for obj in objs if type(obj) == types.ListType])
    tuples = len([obj for obj in objs if type(obj) == types.TupleType])

    For a simple program, which just prints values of a dict object, I get the following:

    Objects: 2920
    Modules: 36
    Classes: 74
    Functions: 1057
    Dictionaries: 193
    Lists: 49
    Tuples: 1419

    Are there that many objects/functions/etc. used by my simple program? How? Why?

    Thanks.
Working...