diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py index 77f1c3cd3e..67ccff6bf8 100644 --- a/direct/src/distributed/ConnectionRepository.py +++ b/direct/src/distributed/ConnectionRepository.py @@ -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) diff --git a/direct/src/showbase/GarbageReport.py b/direct/src/showbase/GarbageReport.py index 8ed2afc3d2..298d71991f 100755 --- a/direct/src/showbase/GarbageReport.py +++ b/direct/src/showbase/GarbageReport.py @@ -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()