shift-f11 logs garbage cycle info and reports results in the client

This commit is contained in:
Darren Ranalli 2009-01-22 19:19:37 +00:00
parent e53843ec11
commit 07461ccbdd
2 changed files with 13 additions and 10 deletions

View File

@ -136,8 +136,8 @@ class ConnectionRepository(
# populated before we start increasing the auto-collect threshold
# don't distribute the leak check from the client to the AI, they both
# do these garbage checks independently over time
leakExists = GarbageReport.checkForGarbageLeaks()
if not leakExists:
numGarbage = GarbageReport.checkForGarbageLeaks()
if numGarbage == 0:
self.gcNotify.debug('no garbage found, doubling gc threshold')
a, b, c = gc.get_threshold()
gc.set_threshold(min(a * 2, 1 << 30), b, c)

View File

@ -516,18 +516,22 @@ class GarbageLogger(GarbageReport):
def checkForGarbageLeaks():
gc.collect()
leakExists = (len(gc.garbage) > 0)
if leakExists and (not config.GetBool('allow-garbage-cycles', 1)):
numGarbage = len(gc.garbage)
if numGarbage:
print
gr = GarbageLogger('found garbage', threaded=False)
print
notify = directNotify.newCategory("GarbageDetect")
notify.error('%s garbage cycles found, see info above' % gr.getNumCycles())
return leakExists
if config.GetBool('allow-garbage-cycles', 1):
func = notify.warning
else:
func = notify.error
func('%s garbage cycles found, see info above' % gr.getNumCycles())
return numGarbage
def b_checkForGarbageLeaks():
# does a garbage collect
# returns True if there is a garbage leak, False otherwise
# does a garbage collect on the client and the AI
# returns number of client garbage leaks
# logs leak info and terminates (if configured to do so)
try:
# if this is the client, tell the AI to check for leaks too
@ -537,5 +541,4 @@ def b_checkForGarbageLeaks():
else:
if base.cr.timeManager:
base.cr.timeManager.d_checkForGarbageLeaks()
checkForGarbageLeaks()
return checkForGarbageLeaks()