def writeElementSet(l, f):
    myDict = {}

    for he in l:
        if he.backtraces:
            bt = backtrace_element(he.backtraces)
            if bt in myDict:
                l = myDict[bt]
                l[0] += he.size
                l.append(he.addr)
            else:
                myDict[bt] = [he.size, he.addr]
    def getSortKey(item):
        return item[1][0]

    sortedItemList = sorted(myDict.iteritems(), key=getSortKey, reverse=True)
    if not sortedItemList:
        return False
    
    for item in sortedItemList:
# for backward compatibility
        l = item[1]

        print >>f, "Address: " + " ".join(["{0:08x}".format(num) for num in l[1:] ])
        print >>f, "Size: {0}".format(l[0])
        print >>f, "Backtraces:"
        if item[0]._backtraces:
            for b in item[0]._backtraces:
                print >>f , "0x{0:08X}".format(b)
        print >>f, ""
    return True
Exemplo n.º 2
0
def writeElementSet(l, f):
    myDict = {}

    for he in l:
        if he.backtraces:
            bt = backtrace_element(he.backtraces)
            if bt in myDict:
                l = myDict[bt]
                l[0] += he.size
                l.append(he.addr)
            else:
                myDict[bt] = [he.size, he.addr]
    def getSortKey(item):
        return item[1][0]

    sortedItemList = sorted(myDict.iteritems(), key=getSortKey, reverse=True)
    if not sortedItemList:
        return False
    
    for item in sortedItemList:
# for backward compatibility
        l = item[1]

        print >>f, "Address: " + " ".join(["{0:08x}".format(num) for num in l[1:] ])
        print >>f, "Size: {0}".format(l[0])
        print >>f, "Backtraces:"
        if item[0]._backtraces:
            for b in item[0]._backtraces:
                print >>f , "0x{0:08X}".format(b)
        print >>f, ""
    return True
def assignExtendAttr(node,BOMapping):
    if not hasattr(node,'children_'):
        setattr(node,'children_',None)
        setattr(node,'totalWeight_',len(node.userContent))
        #search for object type
        typeTuple = ('Unknown',)
        if node.backtraces:
            bt = backtrace_element(node.backtraces)
            if bt in BOMapping:
                typeTuple = BOMapping[bt]
        setattr(node,'typeTuple_',typeTuple)
def initObjDict(objDict,fileName):
    g = analyze.HeapGraph()
    with open(fileName,'r') as f:
        l = analyze.parse(g,f)
    del g
    for outData in l:
        if outData.special or not outData.backtraces:
            continue
        bt = backtrace_element(outData.backtraces)
        if bt not in objDict:
            objDict[bt] = OldObjectDesc(outData.size,outData.backtraces)
        else:
            oldDesc = objDict[bt]
            oldDesc.allocations += outData.size
def initObjDict(objDict,fileName):
    g = analyze.HeapGraph()
    generalList = None
    with open(fileName,'rb') as f:
        generalList = analyze.parse(g,f)

    for outData in generalList:
        if not outData.backtraces:
            continue
        backtrace = backtrace_element(outData.backtraces)
        if backtrace not in objDict:
            objDict[backtrace] = OldObjectDesc(outData.size,outData.backtraces)
        else:
            oldDesc = objDict[backtrace]
            oldDesc.allocations +=  outData.size
Exemplo n.º 6
0
def initObjDict(objDict, fileName):
    g = analyze.HeapGraph()
    generalList = None
    with open(fileName, 'rb') as f:
        generalList = analyze.parse(g, f)

    for outData in generalList:
        if not outData.backtraces:
            continue
        backtrace = backtrace_element(outData.backtraces)
        if backtrace not in objDict:
            objDict[backtrace] = OldObjectDesc(outData.size,
                                               outData.backtraces)
        else:
            oldDesc = objDict[backtrace]
            oldDesc.allocations += outData.size
def printBackTrace(generalList, fileDesc = sys.stdout):
    myDict = {}
    for e in generalList:
        if not e.backtraces:
            continue
        bt = backtrace_element(e.backtraces)
        if bt in myDict:
            myDict[bt] += e.size
        else:
            myDict[bt] = e.size

    myitem = sorted(myDict.iteritems(), key=operator.itemgetter(1), reverse=True)

    for item in myitem:
        print >>fileDesc, "Allocation: {0}".format(item[1])
        for b in item[0]._backtraces:
            print >>fileDesc, "0x{0:08X}".format(b)
        print >>fileDesc, ""
    fileDesc.flush()
    return tuple(x[0] for x in myitem)
Exemplo n.º 8
0
def printBackTrace(generalList, fileDesc = sys.stdout):
    myDict = {}
    for e in generalList:
        if not e.backtraces:
            continue
        bt = backtrace_element(e.backtraces)
        if bt in myDict:
            myDict[bt] += e.size
        else:
            myDict[bt] = e.size

    myitem = sorted(myDict.iteritems(), key=operator.itemgetter(1), reverse=True)

    for item in myitem:
        print >>fileDesc, "Allocation: {0}".format(item[1])
        for b in item[0]._backtraces:
            print >>fileDesc, "0x{0:08X}".format(b)
        print >>fileDesc, ""
    fileDesc.flush()
    return tuple(x[0] for x in myitem)
 def __init__(self,size,allocations,backtraces):
     self.size = size
     self.allocations = allocations
     self.backtraces = backtrace_element(backtraces)
Exemplo n.º 10
0
 def __init__(self, size, allocations, backtraces):
     self.size = size
     self.allocations = allocations
     self.backtraces = backtrace_element(backtraces)