mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
log number of garbage cycles even if we've previously printed the full info on those cycles
This commit is contained in:
parent
9633f32bfa
commit
fcfd9f8e20
@ -514,8 +514,9 @@ class GarbageReport(Job):
|
|||||||
class GarbageLogger(GarbageReport):
|
class GarbageLogger(GarbageReport):
|
||||||
"""If you just want to log the current garbage to the log file, make
|
"""If you just want to log the current garbage to the log file, make
|
||||||
one of these. It automatically destroys itself after logging"""
|
one of these. It automatically destroys itself after logging"""
|
||||||
# variable for checkForGarbageLeaks
|
# for checkForGarbageLeaks
|
||||||
LastNumGarbage = 0
|
LastNumGarbage = 0
|
||||||
|
LastNumCycles = 0
|
||||||
def __init__(self, name, *args, **kArgs):
|
def __init__(self, name, *args, **kArgs):
|
||||||
kArgs['log'] = True
|
kArgs['log'] = True
|
||||||
kArgs['autoDestroy'] = True
|
kArgs['autoDestroy'] = True
|
||||||
@ -524,18 +525,20 @@ class GarbageLogger(GarbageReport):
|
|||||||
def checkForGarbageLeaks():
|
def checkForGarbageLeaks():
|
||||||
gc.collect()
|
gc.collect()
|
||||||
numGarbage = len(gc.garbage)
|
numGarbage = len(gc.garbage)
|
||||||
if ((numGarbage != GarbageLogger.LastNumGarbage) and
|
if (numGarbage > 0 and (not configIsToday('disable-garbage-logging'))):
|
||||||
(not configIsToday('disable-garbage-logging'))):
|
if (numGarbage != GarbageLogger.LastNumGarbage):
|
||||||
GarbageLogger.LastNumGarbage = numGarbage
|
|
||||||
print
|
print
|
||||||
gr = GarbageLogger('found garbage', threaded=False, collect=False)
|
gr = GarbageLogger('found garbage', threaded=False, collect=False)
|
||||||
print
|
print
|
||||||
|
GarbageLogger.LastNumGarbage = numGarbage
|
||||||
|
GarbageLogger.LastNumCycles = gr.getNumCycles()
|
||||||
notify = directNotify.newCategory("GarbageDetect")
|
notify = directNotify.newCategory("GarbageDetect")
|
||||||
if config.GetBool('allow-garbage-cycles', 1):
|
if config.GetBool('allow-garbage-cycles', 1):
|
||||||
func = notify.warning
|
func = notify.warning
|
||||||
else:
|
else:
|
||||||
func = notify.error
|
func = notify.error
|
||||||
func('%s garbage cycles found, see info above' % gr.getNumCycles())
|
func('%s garbage cycles found, see info above' %
|
||||||
|
GarbageLogger.LastNumCycles)
|
||||||
return numGarbage
|
return numGarbage
|
||||||
|
|
||||||
def b_checkForGarbageLeaks(wantReply=False):
|
def b_checkForGarbageLeaks(wantReply=False):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user