Пример #1
0
    def dump(self):
	gc.collect()
	self.xmemstats()
	#print 'len alset', len(self.alset)

	V = self.V
	R = self.R
	P = self.P
	nrefs = self.nrefs
	if 0:
	    h = self.h

	    n = h.news(gc.get_objects())
	    print V.retset(n)
	    if len(n) <= 12:
		l = list(n)
		for i in range(len(n)):
		    V.enter(
			lambda : P.shpaths((), l[i]).pp())
	try:
	    co = sys.getcounts()
	except AttributeError:
	    pass
	else:
	    for (name, allo, free, max) in co:
		nref = allo - free
		if name not in nrefs or nref != nrefs[name]:
		    print >>sys.stderr, (name, nref),
		    nrefs[name] = nref
	    print >>sys.stderr
	h=self.h=n=co=name=allo=free=max=l=i=None
	#self.mark()
	#self.alset = None
	#R.guppy.heapy.heapyc.clr_alset()
	gc.collect()
Пример #2
0
    def dump(self):
        gc.collect()
        self.xmemstats()

        V = self.V
        R = self.R
        P = self.P
        nrefs = self.nrefs

        try:
            co = sys.getcounts()
        except AttributeError:
            pass
        else:
            for (name, allo, free, max) in co:
                nref = allo - free
                if name not in nrefs or nref != nrefs[name]:
                    print((name, nref), end=' ', file=sys.stderr)
                    nrefs[name] = nref
            print(file=sys.stderr)
        h = self.h = n = co = name = allo = free = max = l = i = None
        # self.mark()
        #self.alset = None
        # R.guppy.heapy.heapyc.clr_alset()
        gc.collect()
Пример #3
0
def printDebuggingInfo():
    # Don't try to print the refcount info if this build of Python wasn't
    # configured with sufficient debugosity (see Misc/SpecialBuilds.txt in the
    # Python source distribution).
    if not (hasattr(sys, 'gettotalrefcount') and hasattr(sys, 'getcounts')):
        return

    collectCount = gc.collect()
    pr(DIVIDER_1)
    pr('EXTREME_DEBUG Report')
    pr(DIVIDER_1)
    pr('collectCount: %d' % collectCount)
    pr('sys.gettotalrefcount(): %d' % sys.gettotalrefcount())

    pr(DIVIDER_1)
    counts = sys.getcounts()

    typeStats = {}
    for (tp_name, tp_allocs, tp_frees, tp_maxalloc) in counts:
        typeStats[tp_name] = {'allocs': tp_allocs, 'frees': tp_frees, 'maxalloc': tp_maxalloc}

    for (tp_name, tp_allocs, tp_frees, tp_maxalloc) in counts:
        if 'Test' in tp_name:
            continue
        if tp_allocs != tp_frees:
            def doStatsOffset(companionStats):
                return (
                       (abs(tp_allocs - tp_frees) == companionStats['frees'])
                    or (abs(tp_frees - tp_allocs) == companionStats['allocs'])
                  )

            if tp_name.endswith('Ptr') and tp_name[:-3] in typeStats:
                companionTypeName = tp_name[:-3]
                companionStats = typeStats[companionTypeName]
                if doStatsOffset(companionStats):
                    pr('%s offset by companion %s' % (
                        tp_name.ljust(40), companionTypeName
                      ))
                    continue
            elif tp_name + 'Ptr' in typeStats:
                companionTypeName = tp_name + 'Ptr'
                companionStats = typeStats[companionTypeName]
                if doStatsOffset(companionStats):
                    pr('%s offset by companion %s' % (
                        tp_name.ljust(40), companionTypeName
                      ))
                    continue


            pr('%s (%s)' % (tp_name.ljust(50), str(tp_allocs - tp_frees).rjust(7)))
    pr(DIVIDER_1)

    sys.stderr.flush()