Browse Source

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

Darren Ranalli 17 years ago
parent
commit
07461ccbdd

+ 2 - 2
direct/src/distributed/ConnectionRepository.py

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

+ 11 - 8
direct/src/showbase/GarbageReport.py

@@ -516,18 +516,22 @@ class GarbageLogger(GarbageReport):
 
 
 def checkForGarbageLeaks():
 def checkForGarbageLeaks():
     gc.collect()
     gc.collect()
-    leakExists = (len(gc.garbage) > 0)
-    if leakExists and (not config.GetBool('allow-garbage-cycles', 1)):
+    numGarbage = len(gc.garbage)
+    if numGarbage:
         print
         print
         gr = GarbageLogger('found garbage', threaded=False)
         gr = GarbageLogger('found garbage', threaded=False)
         print
         print
         notify = directNotify.newCategory("GarbageDetect")
         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():
 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)
     # logs leak info and terminates (if configured to do so)
     try:
     try:
         # if this is the client, tell the AI to check for leaks too
         # if this is the client, tell the AI to check for leaks too
@@ -537,5 +541,4 @@ def b_checkForGarbageLeaks():
     else:
     else:
         if base.cr.timeManager:
         if base.cr.timeManager:
             base.cr.timeManager.d_checkForGarbageLeaks()
             base.cr.timeManager.d_checkForGarbageLeaks()
-    checkForGarbageLeaks()
-    
+    return checkForGarbageLeaks()