def _getRefCounts():
"""
Return information about all object allocated and the number of
references pointing to each object. This can be used to check a running
server for memory (object) leaks.
Taken from: http://www.nightmare.com/medusa/memory-leaks.html.
Returns:
"""
T = TRACE()
d = {}
sys.modules
# Collect all classes
for m in sys.modules.values():
for sym in dir(m):
o = getattr (m, sym)
if type(o) is types.ClassType:
d[o] = sys.getrefcount (o)
# sort by refcount
pairs = map(lambda x: (x[1],x[0]), d.items())
pairs.sort()
pairs.reverse()
return pairs
评论列表
文章目录