ngamsStatusCmd.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ngas 作者: ICRAR 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号