mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
added support for _garbageInfo custom info callback
This commit is contained in:
parent
8078c69995
commit
a975e14907
@ -132,6 +132,8 @@ class GarbageReport(Job):
|
||||
self.referentsByReference = {}
|
||||
self.referentsByNumber = {}
|
||||
|
||||
self._id2garbageInfo = {}
|
||||
|
||||
self.cycles = []
|
||||
self.cyclesBySyntax = []
|
||||
self.uniqueCycleSets = set()
|
||||
@ -167,6 +169,18 @@ class GarbageReport(Job):
|
||||
self.referentsByNumber[i] = byNum
|
||||
self.referentsByReference[i] = byRef
|
||||
|
||||
for i in xrange(self.numGarbage):
|
||||
if hasattr(self.garbage[i], '_garbageInfo') and callable(self.garbage[i]._garbageInfo):
|
||||
try:
|
||||
info = self.garbage[i]._garbageInfo()
|
||||
except Exception, e:
|
||||
info = str(e)
|
||||
self._id2garbageInfo[id(self.garbage[i])] = info
|
||||
yield None
|
||||
else:
|
||||
if not (i % 20):
|
||||
yield None
|
||||
|
||||
# find the cycles
|
||||
if self._args.findCycles and self.numGarbage > 0:
|
||||
if self._args.verbose:
|
||||
@ -335,6 +349,16 @@ class GarbageReport(Job):
|
||||
yield None
|
||||
s.append('%s:%s' % (ac.next(), self.cyclesBySyntax[i]))
|
||||
|
||||
if len(self._id2garbageInfo):
|
||||
s.append('===== Garbage Custom Info =====')
|
||||
ac = AlphabetCounter()
|
||||
for i in xrange(len(self.cyclesBySyntax)):
|
||||
yield None
|
||||
counter = ac.next()
|
||||
_id = id(self.garbage[i])
|
||||
if _id in self._id2garbageInfo:
|
||||
s.append('%s:%s' % (counter, self._id2garbageInfo[_id]))
|
||||
|
||||
if self._args.fullReport:
|
||||
format = '%0' + '%s' % digits + 'i:%s'
|
||||
s.append('===== Referrers By Number (what is referring to garbage item?) =====')
|
||||
|
Loading…
x
Reference in New Issue
Block a user